Skip to content

Commit

Permalink
Ref #214: make new fields nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
LucileDT committed Dec 25, 2020
1 parent fa927cf commit f13dc5b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/Entity/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ class Payment

/**
* When the payment is made by check, save the check number
* @ORM\Column(type="string", length=40)
* @ORM\Column(type="string", length=40, nullable=true)
*/
private $check_number;

/**
* When the payment is made by check, save the check issuer
* @ORM\Column(type="string", length=300)
* @ORM\Column(type="string", length=300, nullable=true)
*/
private $check_issuer;

Expand Down Expand Up @@ -252,4 +252,26 @@ public function setReceipt(Receipt $receipt): self

return $this;
}

function getCheckNumber(): ?string
{
return $this->check_number;
}

function getCheckIssuer(): ?string
{
return $this->check_issuer;
}

function setCheckNumber($check_number): self
{
$this->check_number = $check_number;
return $this;
}

function setCheckIssuer($check_issuer): self
{
$this->check_issuer = $check_issuer;
return $this;
}
}
26 changes: 26 additions & 0 deletions src/Migrations/Version20201224233508.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20201224233508 extends AbstractMigration
{
public function getDescription() : string
{
return 'Make optionnal payment parameters nullable.';
}

public function up(Schema $schema) : void
{
$this->addSql('ALTER TABLE payment CHANGE check_number check_number VARCHAR(40) DEFAULT NULL, CHANGE check_issuer check_issuer VARCHAR(300) DEFAULT NULL');
}

public function down(Schema $schema) : void
{
$this->addSql('ALTER TABLE payment CHANGE check_number check_number VARCHAR(40) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE check_issuer check_issuer VARCHAR(300) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
}
}

0 comments on commit f13dc5b

Please sign in to comment.