migrations/Version20210621115728.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 Version20210621115728 extends AbstractMigration
  10. {
  11.     public function getDescription() : string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema) : void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE cal_maintenance (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, category_id INT DEFAULT NULL, comment LONGTEXT DEFAULT NULL, created_at DATETIME DEFAULT NULL, INDEX IDX_BE7ADFFA76ED395 (user_id), INDEX IDX_BE7ADFF12469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE cal_maintenance_category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, position INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE cal_maintenance_category_choices (maintenance_category_source INT NOT NULL, maintenance_category_target INT NOT NULL, INDEX IDX_E965C0C21CFD24E0 (maintenance_category_source), INDEX IDX_E965C0C2518746F (maintenance_category_target), PRIMARY KEY(maintenance_category_source, maintenance_category_target)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE cal_maintenance ADD CONSTRAINT FK_BE7ADFFA76ED395 FOREIGN KEY (user_id) REFERENCES cal_user (id)');
  22.         $this->addSql('ALTER TABLE cal_maintenance ADD CONSTRAINT FK_BE7ADFF12469DE2 FOREIGN KEY (category_id) REFERENCES cal_maintenance_category (id)');
  23.         $this->addSql('ALTER TABLE cal_maintenance_category_choices ADD CONSTRAINT FK_E965C0C21CFD24E0 FOREIGN KEY (maintenance_category_source) REFERENCES cal_maintenance_category (id) ON DELETE CASCADE');
  24.         $this->addSql('ALTER TABLE cal_maintenance_category_choices ADD CONSTRAINT FK_E965C0C2518746F FOREIGN KEY (maintenance_category_target) REFERENCES cal_maintenance_category (id) ON DELETE CASCADE');
  25.     }
  26.     public function down(Schema $schema) : void
  27.     {
  28.         // this down() migration is auto-generated, please modify it to your needs
  29.         $this->addSql('ALTER TABLE cal_maintenance DROP FOREIGN KEY FK_BE7ADFF12469DE2');
  30.         $this->addSql('ALTER TABLE cal_maintenance_category_choices DROP FOREIGN KEY FK_E965C0C21CFD24E0');
  31.         $this->addSql('ALTER TABLE cal_maintenance_category_choices DROP FOREIGN KEY FK_E965C0C2518746F');
  32.         $this->addSql('DROP TABLE cal_maintenance');
  33.         $this->addSql('DROP TABLE cal_maintenance_category');
  34.         $this->addSql('DROP TABLE cal_maintenance_category_choices');
  35.     }
  36. }