migrations/Version20181120232322.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 Version20181120232322 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('
  16.             CREATE TABLE lead_comment (
  17.                 id INT AUTO_INCREMENT NOT NULL,
  18.                 lead_id INT DEFAULT NULL,
  19.                 user_id INT DEFAULT NULL,
  20.                 body LONGTEXT NOT NULL,
  21.                 created_at DATETIME NOT NULL,
  22.                 modified_at DATETIME NOT NULL,
  23.                 INDEX IDX_CDBA0E0255458D (lead_id),
  24.                 INDEX IDX_CDBA0E02A76ED395 (user_id),
  25.                 PRIMARY KEY(id)
  26.             ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
  27.         ');
  28.         $this->addSql('ALTER TABLE lead_comment ADD CONSTRAINT FK_CDBA0E0255458D FOREIGN KEY (lead_id) REFERENCES lead (id) ON DELETE CASCADE');
  29.         $this->addSql('ALTER TABLE lead_comment ADD CONSTRAINT FK_CDBA0E02A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE SET NULL');
  30.     }
  31.     public function down(Schema $schema): void
  32.     {
  33.         // this down() migration is auto-generated, please modify it to your needs
  34.         $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
  35.         $this->addSql('DROP TABLE lead_comment');
  36.     }
  37. }