migrations/2020/06/Version20200603131319.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20200603131319 extends AbstractMigration
  7. {
  8.     public function up(Schema $schema): void
  9.     {
  10.         $this->addSql('CREATE TABLE invoice_payment (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary)\', created_by_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary)\', invoice_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', paid_on DATE NOT NULL COMMENT \'(DC2Type:date_immutable)\', amount BIGINT NOT NULL, INDEX IDX_9FF1B2DEB03A8386 (created_by_id), INDEX IDX_9FF1B2DE2989F1FD (invoice_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  11.         $this->addSql('ALTER TABLE invoice_payment ADD CONSTRAINT FK_9FF1B2DEB03A8386 FOREIGN KEY (created_by_id) REFERENCES contact (id)');
  12.         $this->addSql('ALTER TABLE invoice_payment ADD CONSTRAINT FK_9FF1B2DE2989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id)');
  13.         $this->addSql('ALTER TABLE invoice ADD payments_total BIGINT NOT NULL');
  14.     }
  15.     public function down(Schema $schema): void
  16.     {
  17.         $this->addSql('DROP TABLE invoice_payment');
  18.         $this->addSql('ALTER TABLE invoice DROP payments_total');
  19.     }
  20. }