migrations/2021/04/Version20210413115727.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 Version20210413115727 extends AbstractMigration
  7. {
  8.     public function up(Schema $schema): void
  9.     {
  10.         $this->addSql('CREATE TABLE app_notification (id BINARY(16) NOT NULL COMMENT \'(DC2Type:notification_id)\', recipient_id BINARY(16) NOT NULL COMMENT \'(DC2Type:contact_id)\', sender_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:contact_id)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', subject VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, INDEX IDX_7DDA6C4BE92F8F78 (recipient_id), INDEX IDX_7DDA6C4BF624B39D (sender_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  11.         $this->addSql('CREATE TABLE app_notification_log (id BINARY(16) NOT NULL COMMENT \'(DC2Type:notification_log_id)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:contact_id)\', notification_id BINARY(16) NOT NULL COMMENT \'(DC2Type:notification_id)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_9AEFBC53B03A8386 (created_by_id), INDEX IDX_9AEFBC53EF1A9D84 (notification_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  12.         $this->addSql('CREATE TABLE app_notification_scheduler (id BINARY(16) NOT NULL COMMENT \'(DC2Type:notification_scheduler_id)\', recipient_id BINARY(16) NOT NULL COMMENT \'(DC2Type:contact_id)\', sender_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:contact_id)\', active_from DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', active_to DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', last_run_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_CDCF18DDE92F8F78 (recipient_id), INDEX IDX_CDCF18DDF624B39D (sender_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  13.         $this->addSql('ALTER TABLE app_notification ADD CONSTRAINT FK_7DDA6C4BE92F8F78 FOREIGN KEY (recipient_id) REFERENCES contact (id)');
  14.         $this->addSql('ALTER TABLE app_notification ADD CONSTRAINT FK_7DDA6C4BF624B39D FOREIGN KEY (sender_id) REFERENCES contact (id)');
  15.         $this->addSql('ALTER TABLE app_notification_log ADD CONSTRAINT FK_9AEFBC53B03A8386 FOREIGN KEY (created_by_id) REFERENCES contact (id)');
  16.         $this->addSql('ALTER TABLE app_notification_log ADD CONSTRAINT FK_9AEFBC53EF1A9D84 FOREIGN KEY (notification_id) REFERENCES app_notification (id)');
  17.         $this->addSql('ALTER TABLE app_notification_scheduler ADD CONSTRAINT FK_CDCF18DDE92F8F78 FOREIGN KEY (recipient_id) REFERENCES contact (id)');
  18.         $this->addSql('ALTER TABLE app_notification_scheduler ADD CONSTRAINT FK_CDCF18DDF624B39D FOREIGN KEY (sender_id) REFERENCES contact (id)');
  19.         $this->addSql('DROP INDEX UNIQ_9065174439E6FA16 ON invoice');
  20.         $this->addSql('ALTER TABLE invoice DROP old_id');
  21.     }
  22.     public function down(Schema $schema): void
  23.     {
  24.         $this->addSql('ALTER TABLE app_notification_log DROP FOREIGN KEY FK_9AEFBC53EF1A9D84');
  25.         $this->addSql('DROP TABLE app_notification');
  26.         $this->addSql('DROP TABLE app_notification_log');
  27.         $this->addSql('DROP TABLE app_notification_scheduler');
  28.         $this->addSql('ALTER TABLE invoice ADD old_id INT DEFAULT NULL');
  29.         $this->addSql('CREATE UNIQUE INDEX UNIQ_9065174439E6FA16 ON invoice (old_id)');
  30.     }
  31. }