migrations/Version20180919164930.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20180919164930 extends AbstractMigration
  10. {
  11.     public function up(Schema $schema): void
  12.     {
  13.         // this up() migration is auto-generated, please modify it to your needs
  14.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  15.         $this->addSql('DROP TABLE notifications');
  16.         $this->addSql('
  17.             CREATE TABLE notification (
  18.                 id INT AUTO_INCREMENT NOT NULL,
  19.                 user_id INT DEFAULT NULL,
  20.                 actor_id INT DEFAULT NULL,
  21.                 customer_id INT DEFAULT NULL,
  22.                 comment_id INT DEFAULT NULL,
  23.                 message_id INT DEFAULT NULL,
  24.                 file_id INT DEFAULT NULL,
  25.                 upsell_request_id INT DEFAULT NULL,
  26.                 lead_id INT DEFAULT NULL,
  27.                 event_id INT DEFAULT NULL,
  28.                 issue_id INT DEFAULT NULL,
  29.                 feed_id INT DEFAULT NULL,
  30.                 command ENUM(\'created_object\', \'created_comment\', \'assigned_customer\', \'assigned_lead\', \'assigned_event\', \'assigned_issue\', \'assigned_feed\', \'event_poked\', \'event_reminder\', \'event_is_due\', \'message_sent\') NOT NULL COMMENT \'(DC2Type:NotificationCommandType)\',
  31.                 params LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\',
  32.                 unread TINYINT(1) NOT NULL,
  33.                 created_at DATETIME NOT NULL,
  34.                 type ENUM(\'system\', \'customer\', \'customer_comment\', \'customer_message\', \'customer_file\', \'customer_upsell_request\', \'lead\', \'event\', \'issue\', \'feed\') NOT NULL COMMENT \'(DC2Type:NotificationSectionType)\',
  35.                 INDEX IDX_BF5476CAA76ED395 (user_id),
  36.                 INDEX IDX_BF5476CA10DAF24A (actor_id),
  37.                 INDEX IDX_BF5476CA9395C3F3 (customer_id),
  38.                 INDEX IDX_BF5476CAF8697D13 (comment_id),
  39.                 INDEX IDX_BF5476CA537A1329 (message_id),
  40.                 INDEX IDX_BF5476CA93CB796C (file_id),
  41.                 INDEX IDX_BF5476CA6A6F8AD7 (upsell_request_id),
  42.                 INDEX IDX_BF5476CA55458D (lead_id),
  43.                 INDEX IDX_BF5476CA71F7E88B (event_id),
  44.                 INDEX IDX_BF5476CA5E7AA58C (issue_id),
  45.                 INDEX IDX_BF5476CA51A5BC03 (feed_id),
  46.                 PRIMARY KEY(id)
  47.             ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
  48.         ');
  49.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
  50.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA10DAF24A FOREIGN KEY (actor_id) REFERENCES user (id) ON DELETE SET NULL');
  51.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE');
  52.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CAF8697D13 FOREIGN KEY (comment_id) REFERENCES customer_comment (id) ON DELETE CASCADE');
  53.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA537A1329 FOREIGN KEY (message_id) REFERENCES customer_message (id) ON DELETE CASCADE');
  54.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA93CB796C FOREIGN KEY (file_id) REFERENCES customer_file (id) ON DELETE CASCADE');
  55.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA6A6F8AD7 FOREIGN KEY (upsell_request_id) REFERENCES customer_upsell_request (id) ON DELETE CASCADE');
  56.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA55458D FOREIGN KEY (lead_id) REFERENCES lead (id) ON DELETE CASCADE');
  57.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA71F7E88B FOREIGN KEY (event_id) REFERENCES event (id) ON DELETE CASCADE');
  58.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA5E7AA58C FOREIGN KEY (issue_id) REFERENCES issue (id) ON DELETE CASCADE');
  59.         $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA51A5BC03 FOREIGN KEY (feed_id) REFERENCES feed (id) ON DELETE CASCADE');
  60.     }
  61.     public function down(Schema $schema): void
  62.     {
  63.         // this down() migration is auto-generated, please modify it to your needs
  64.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  65.         $this->addSql('DROP TABLE notification');
  66.         $this->addSql('
  67.             CREATE TABLE notifications (
  68.                 id INT AUTO_INCREMENT NOT NULL,
  69.                 administrators_id INT NOT NULL,
  70.                 object_name VARCHAR(255) DEFAULT NULL COLLATE latin1_swedish_ci,
  71.                 object_id INT NOT NULL,
  72.                 parameters LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\',
  73.                 date_added DATETIME DEFAULT NULL,
  74.                 last_modified DATETIME DEFAULT NULL,
  75.                 INDEX idx_administrators_id (administrators_id),
  76.                 INDEX idx_object (object_name, object_id),
  77.                 PRIMARY KEY(id)
  78.             ) DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ENGINE = MyISAM
  79.         ');
  80.     }
  81. }