migrations/Version20211014090916.php line 1

  1. <?php declare(strict_types=1);
  2. namespace DoctrineMigrations;
  3. use Doctrine\DBAL\Schema\Schema;
  4. use Doctrine\Migrations\AbstractMigration;
  5. /**
  6.  * Auto-generated Migration: Please modify to your needs!
  7.  */
  8. final class Version20211014090916 extends AbstractMigration
  9. {
  10.     public function up(Schema $schema) : void
  11.     {
  12.         // this up() migration is auto-generated, please modify it to your needs
  13.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  14.         $this->addSql('CREATE SEQUENCE seq_scenario_timetrack_id INCREMENT BY 1 MINVALUE 1 START 1');
  15.         $this->addSql('CREATE TABLE scenario_timetrack (id INT NOT NULL, users_id INT DEFAULT NULL, node_id INT NOT NULL, scenario_id INT NOT NULL, session_id VARCHAR(128) DEFAULT NULL, time TIME(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
  16.         $this->addSql('CREATE INDEX IDX_BD1F5CE667B3B43D ON scenario_timetrack (users_id)');
  17.         $this->addSql('CREATE INDEX IDX_BD1F5CE6460D9FD7 ON scenario_timetrack (node_id)');
  18.         $this->addSql('CREATE INDEX IDX_BD1F5CE6E04E49DF ON scenario_timetrack (scenario_id)');
  19.         $this->addSql('COMMENT ON TABLE scenario_timetrack IS \'Table of the times spent on nodes of the scenarios.\'');
  20.         $this->addSql('COMMENT ON COLUMN scenario_timetrack.id IS \'ID\'');
  21.         $this->addSql('ALTER TABLE scenario_timetrack ADD CONSTRAINT FK_BD1F5CE667B3B43D FOREIGN KEY (users_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  22.         $this->addSql('ALTER TABLE scenario_timetrack ADD CONSTRAINT FK_BD1F5CE6460D9FD7 FOREIGN KEY (node_id) REFERENCES node (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  23.         $this->addSql('ALTER TABLE scenario_timetrack ADD CONSTRAINT FK_BD1F5CE6E04E49DF FOREIGN KEY (scenario_id) REFERENCES scenario (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  24.     }
  25.     public function down(Schema $schema) : void
  26.     {
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  29.         $this->addSql('CREATE SCHEMA public');
  30.         $this->addSql('DROP SEQUENCE seq_scenario_timetrack_id CASCADE');
  31.         $this->addSql('DROP TABLE scenario_timetrack');
  32.     }
  33. }