migrations/Version20200407141808.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 Version20200407141808 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 SEQUENCE measurement_settings_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $this->addSql('CREATE SEQUENCE channel_settings_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  21.         $this->addSql('CREATE TABLE measurement_settings (id INT NOT NULL, measurement_id INT DEFAULT NULL, standard_recipe_id INT DEFAULT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
  22.         $this->addSql('CREATE INDEX IDX_D608BD64924EA134 ON measurement_settings (measurement_id)');
  23.         $this->addSql('CREATE INDEX IDX_D608BD64F28BBC1C ON measurement_settings (standard_recipe_id)');
  24.         $this->addSql('COMMENT ON COLUMN measurement_settings.created_at IS \'Date of the entity creation. Should be fixed.\'');
  25.         $this->addSql('COMMENT ON COLUMN measurement_settings.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
  26.         $this->addSql('CREATE TABLE channel_settings (id INT NOT NULL, measurement_setting_id INT DEFAULT NULL, channel_id INT NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
  27.         $this->addSql('CREATE INDEX IDX_92F5D36C3A2F6F4E ON channel_settings (measurement_setting_id)');
  28.         $this->addSql('CREATE INDEX IDX_92F5D36C72F5A1AA ON channel_settings (channel_id)');
  29.         $this->addSql('COMMENT ON COLUMN channel_settings.created_at IS \'Date of the entity creation. Should be fixed.\'');
  30.         $this->addSql('COMMENT ON COLUMN channel_settings.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
  31.         $this->addSql('ALTER TABLE measurement_settings ADD CONSTRAINT FK_D608BD64924EA134 FOREIGN KEY (measurement_id) REFERENCES measurements (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  32.         $this->addSql('ALTER TABLE measurement_settings ADD CONSTRAINT FK_D608BD64F28BBC1C FOREIGN KEY (standard_recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  33.         $this->addSql('ALTER TABLE channel_settings ADD CONSTRAINT FK_92F5D36C3A2F6F4E FOREIGN KEY (measurement_setting_id) REFERENCES measurement_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  34.         $this->addSql('ALTER TABLE channel_settings ADD CONSTRAINT FK_92F5D36C72F5A1AA FOREIGN KEY (channel_id) REFERENCES channels (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  35.         $this->addSql('ALTER TABLE measurements DROP CONSTRAINT fk_71920f21f28bbc1c');
  36.         $this->addSql('DROP INDEX idx_71920f21f28bbc1c');
  37.         $this->addSql('ALTER TABLE measurements DROP standard_recipe_id');
  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 channel_settings DROP CONSTRAINT FK_92F5D36C3A2F6F4E');
  45.         $this->addSql('DROP SEQUENCE measurement_settings_id_seq CASCADE');
  46.         $this->addSql('DROP SEQUENCE channel_settings_id_seq CASCADE');
  47.         $this->addSql('DROP TABLE measurement_settings');
  48.         $this->addSql('DROP TABLE channel_settings');
  49.         $this->addSql('ALTER TABLE measurements ADD standard_recipe_id INT DEFAULT NULL');
  50.         $this->addSql('ALTER TABLE measurements ADD CONSTRAINT fk_71920f21f28bbc1c FOREIGN KEY (standard_recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  51.         $this->addSql('CREATE INDEX idx_71920f21f28bbc1c ON measurements (standard_recipe_id)');
  52.     }
  53. }