<?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 Version20200407141808 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE measurement_settings_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE channel_settings_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$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))');
$this->addSql('CREATE INDEX IDX_D608BD64924EA134 ON measurement_settings (measurement_id)');
$this->addSql('CREATE INDEX IDX_D608BD64F28BBC1C ON measurement_settings (standard_recipe_id)');
$this->addSql('COMMENT ON COLUMN measurement_settings.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN measurement_settings.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$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))');
$this->addSql('CREATE INDEX IDX_92F5D36C3A2F6F4E ON channel_settings (measurement_setting_id)');
$this->addSql('CREATE INDEX IDX_92F5D36C72F5A1AA ON channel_settings (channel_id)');
$this->addSql('COMMENT ON COLUMN channel_settings.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN channel_settings.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('ALTER TABLE measurement_settings ADD CONSTRAINT FK_D608BD64924EA134 FOREIGN KEY (measurement_id) REFERENCES measurements (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE measurement_settings ADD CONSTRAINT FK_D608BD64F28BBC1C FOREIGN KEY (standard_recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE channel_settings ADD CONSTRAINT FK_92F5D36C3A2F6F4E FOREIGN KEY (measurement_setting_id) REFERENCES measurement_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE channel_settings ADD CONSTRAINT FK_92F5D36C72F5A1AA FOREIGN KEY (channel_id) REFERENCES channels (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE measurements DROP CONSTRAINT fk_71920f21f28bbc1c');
$this->addSql('DROP INDEX idx_71920f21f28bbc1c');
$this->addSql('ALTER TABLE measurements DROP standard_recipe_id');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE channel_settings DROP CONSTRAINT FK_92F5D36C3A2F6F4E');
$this->addSql('DROP SEQUENCE measurement_settings_id_seq CASCADE');
$this->addSql('DROP SEQUENCE channel_settings_id_seq CASCADE');
$this->addSql('DROP TABLE measurement_settings');
$this->addSql('DROP TABLE channel_settings');
$this->addSql('ALTER TABLE measurements ADD standard_recipe_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE measurements ADD CONSTRAINT fk_71920f21f28bbc1c FOREIGN KEY (standard_recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX idx_71920f21f28bbc1c ON measurements (standard_recipe_id)');
}
}