<?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 Version20200408104608 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 channel_setting_coefficients_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE channel_setting_coefficients (id INT NOT NULL, parent_id INT NOT NULL, children_id INT NOT NULL, coefficient INT DEFAULT 1 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_A1A3E886727ACA70 ON channel_setting_coefficients (parent_id)');
$this->addSql('CREATE INDEX IDX_A1A3E8863D3D2749 ON channel_setting_coefficients (children_id)');
$this->addSql('COMMENT ON COLUMN channel_setting_coefficients.coefficient IS \'Coefficient.\'');
$this->addSql('COMMENT ON COLUMN channel_setting_coefficients.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN channel_setting_coefficients.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('ALTER TABLE channel_setting_coefficients ADD CONSTRAINT FK_A1A3E886727ACA70 FOREIGN KEY (parent_id) REFERENCES channel_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE channel_setting_coefficients ADD CONSTRAINT FK_A1A3E8863D3D2749 FOREIGN KEY (children_id) REFERENCES channel_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE channel_settings ADD recipe_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE channel_settings ADD name VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE channel_settings ADD number INT DEFAULT NULL');
$this->addSql('ALTER TABLE channel_settings ADD is_average_weighted BOOLEAN DEFAULT \'false\' NOT NULL');
$this->addSql('ALTER TABLE channel_settings ALTER channel_id DROP NOT NULL');
$this->addSql('COMMENT ON COLUMN channel_settings.name IS \'Channel name.\'');
$this->addSql('COMMENT ON COLUMN channel_settings.number IS \'Channel number.\'');
$this->addSql('COMMENT ON COLUMN channel_settings.is_average_weighted IS \'Is average weighted.\'');
$this->addSql('ALTER TABLE channel_settings ADD CONSTRAINT FK_92F5D36C59D8A214 FOREIGN KEY (recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_92F5D36C59D8A214 ON channel_settings (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('DROP SEQUENCE channel_setting_coefficients_id_seq CASCADE');
$this->addSql('DROP TABLE channel_setting_coefficients');
$this->addSql('ALTER TABLE channel_settings DROP CONSTRAINT FK_92F5D36C59D8A214');
$this->addSql('DROP INDEX IDX_92F5D36C59D8A214');
$this->addSql('ALTER TABLE channel_settings DROP recipe_id');
$this->addSql('ALTER TABLE channel_settings DROP name');
$this->addSql('ALTER TABLE channel_settings DROP number');
$this->addSql('ALTER TABLE channel_settings DROP is_average_weighted');
$this->addSql('ALTER TABLE channel_settings ALTER channel_id SET NOT NULL');
}
}