<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210803093010 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE author_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE author (id INT NOT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE author_mooc (author_id INT NOT NULL, mooc_id INT NOT NULL, PRIMARY KEY(author_id, mooc_id))');
$this->addSql('CREATE INDEX IDX_79B2B38AF675F31B ON author_mooc (author_id)');
$this->addSql('CREATE INDEX IDX_79B2B38A255EEB87 ON author_mooc (mooc_id)');
$this->addSql('ALTER TABLE author_mooc ADD CONSTRAINT FK_79B2B38AF675F31B FOREIGN KEY (author_id) REFERENCES author (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE author_mooc ADD CONSTRAINT FK_79B2B38A255EEB87 FOREIGN KEY (mooc_id) REFERENCES mooc (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE author_mooc DROP CONSTRAINT FK_79B2B38AF675F31B');
$this->addSql('DROP SEQUENCE author_id_seq CASCADE');
$this->addSql('DROP TABLE author');
$this->addSql('DROP TABLE author_mooc');
}
}