migrations/Version20220909072530.php line 1

  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 Version20220909072530 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  19.         $this->addSql('CREATE TABLE STAT_SCENARIO (SCENARIO_ID INT NOT NULL, STAT_ID INT NOT NULL, PRIMARY KEY(SCENARIO_ID, STAT_ID))');
  20.         $this->addSql('CREATE INDEX IDX_13CF990955009DD7 ON STAT_SCENARIO (SCENARIO_ID)');
  21.         $this->addSql('CREATE INDEX IDX_13CF9909E5897F1 ON STAT_SCENARIO (STAT_ID)');
  22.         $this->addSql('COMMENT ON COLUMN STAT_SCENARIO.SCENARIO_ID IS \'ID\'');
  23.         $this->addSql('COMMENT ON COLUMN STAT_SCENARIO.STAT_ID IS \'ID\'');
  24.         $this->addSql('CREATE TABLE stat (id INT NOT NULL, description TEXT DEFAULT NULL, date_from TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, date_to TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
  25.         $this->addSql('CREATE INDEX IDX_36AC99F1460D9ASC ON stat (id)');
  26.         $this->addSql('COMMENT ON TABLE stat IS \'\'');
  27.         $this->addSql('COMMENT ON COLUMN stat.id IS \'ID\'');
  28.         $this->addSql('COMMENT ON COLUMN stat.description IS \'Description\'');
  29.         $this->addSql('CREATE TABLE STAT_USERS (USERS_ID INT NOT NULL, STAT_ID INT NOT NULL, PRIMARY KEY(USERS_ID, STAT_ID))');
  30.         $this->addSql('CREATE INDEX IDX_749760F699CD6E91 ON STAT_USERS (USERS_ID)');
  31.         $this->addSql('CREATE INDEX IDX_749760F6E5897F1 ON STAT_USERS (STAT_ID)');
  32.         $this->addSql('COMMENT ON COLUMN STAT_USERS.USERS_ID IS \'ID\'');
  33.         $this->addSql('COMMENT ON COLUMN STAT_USERS.STAT_ID IS \'ID\'');
  34.         $this->addSql('ALTER TABLE STAT_SCENARIO ADD CONSTRAINT FK_13CF990955009DD7 FOREIGN KEY (SCENARIO_ID) REFERENCES scenario (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  35.         $this->addSql('ALTER TABLE STAT_SCENARIO ADD CONSTRAINT FK_13CF9909E5897F1 FOREIGN KEY (STAT_ID) REFERENCES stat (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  36.         $this->addSql('ALTER TABLE STAT_USERS ADD CONSTRAINT FK_749760F699CD6E91 FOREIGN KEY (USERS_ID) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  37.         $this->addSql('ALTER TABLE STAT_USERS ADD CONSTRAINT FK_749760F6E5897F1 FOREIGN KEY (STAT_ID) REFERENCES stat (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  38.     }
  39.     public function down(Schema $schema) : void
  40.     {
  41.         // this down() migration is auto-generated, please modify it to your needs
  42.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  43.         $this->addSql('CREATE SCHEMA public');
  44.         $this->addSql('ALTER TABLE STAT_SCENARIO DROP CONSTRAINT FK_13CF9909E5897F1');
  45.         $this->addSql('ALTER TABLE STAT_USERS DROP CONSTRAINT FK_749760F6E5897F1');
  46.         $this->addSql('DROP TABLE STAT_SCENARIO');
  47.         $this->addSql('DROP TABLE stat');
  48.         $this->addSql('DROP TABLE STAT_USERS');
  49.     }
  50. }