migrations/Version20210803093010.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 Version20210803093010 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 SEQUENCE author_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  19.         $this->addSql('CREATE TABLE author (id INT NOT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  20.         $this->addSql('CREATE TABLE author_mooc (author_id INT NOT NULL, mooc_id INT NOT NULL, PRIMARY KEY(author_id, mooc_id))');
  21.         $this->addSql('CREATE INDEX IDX_79B2B38AF675F31B ON author_mooc (author_id)');
  22.         $this->addSql('CREATE INDEX IDX_79B2B38A255EEB87 ON author_mooc (mooc_id)');
  23.         $this->addSql('ALTER TABLE author_mooc ADD CONSTRAINT FK_79B2B38AF675F31B FOREIGN KEY (author_id) REFERENCES author (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  24.         $this->addSql('ALTER TABLE author_mooc ADD CONSTRAINT FK_79B2B38A255EEB87 FOREIGN KEY (mooc_id) REFERENCES mooc (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  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('CREATE SCHEMA public');
  30.         $this->addSql('ALTER TABLE author_mooc DROP CONSTRAINT FK_79B2B38AF675F31B');
  31.         $this->addSql('DROP SEQUENCE author_id_seq CASCADE');
  32.         $this->addSql('DROP TABLE author');
  33.         $this->addSql('DROP TABLE author_mooc');
  34.     }
  35. }