migrations/Version20210805144632.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 Version20210805144632 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 hosting_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  19.         $this->addSql('CREATE SEQUENCE mooc_session_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $this->addSql('CREATE SEQUENCE session_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  21.         $this->addSql('CREATE TABLE hosting (id INT NOT NULL, mooc_session_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
  22.         $this->addSql('CREATE INDEX IDX_E9168FDAAC16130F ON hosting (mooc_session_id)');
  23.         $this->addSql('CREATE TABLE mooc_session (id INT NOT NULL, mooc_id INT NOT NULL, status VARCHAR(255) DEFAULT NULL, start_date DATE NOT NULL, end_date DATE NOT NULL, PRIMARY KEY(id))');
  24.         $this->addSql('CREATE INDEX IDX_8A28C02B255EEB87 ON mooc_session (mooc_id)');
  25.         $this->addSql('CREATE TABLE session (id INT NOT NULL, PRIMARY KEY(id))');
  26.         $this->addSql('ALTER TABLE hosting ADD CONSTRAINT FK_E9168FDAAC16130F FOREIGN KEY (mooc_session_id) REFERENCES mooc_session (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  27.         $this->addSql('ALTER TABLE mooc_session ADD CONSTRAINT FK_8A28C02B255EEB87 FOREIGN KEY (mooc_id) REFERENCES mooc (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  28.     }
  29.     public function down(Schema $schema): void
  30.     {
  31.         // this down() migration is auto-generated, please modify it to your needs
  32.         $this->addSql('CREATE SCHEMA public');
  33.         $this->addSql('ALTER TABLE hosting DROP CONSTRAINT FK_E9168FDAAC16130F');
  34.         $this->addSql('DROP SEQUENCE hosting_id_seq CASCADE');
  35.         $this->addSql('DROP SEQUENCE mooc_session_id_seq CASCADE');
  36.         $this->addSql('DROP SEQUENCE session_id_seq CASCADE');
  37.         $this->addSql('DROP TABLE hosting');
  38.         $this->addSql('DROP TABLE mooc_session');
  39.         $this->addSql('DROP TABLE session');
  40.     }
  41. }