migrations/Version20200408104608.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 Version20200408104608 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 channel_setting_coefficients_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $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))');
  21.         $this->addSql('CREATE INDEX IDX_A1A3E886727ACA70 ON channel_setting_coefficients (parent_id)');
  22.         $this->addSql('CREATE INDEX IDX_A1A3E8863D3D2749 ON channel_setting_coefficients (children_id)');
  23.         $this->addSql('COMMENT ON COLUMN channel_setting_coefficients.coefficient IS \'Coefficient.\'');
  24.         $this->addSql('COMMENT ON COLUMN channel_setting_coefficients.created_at IS \'Date of the entity creation. Should be fixed.\'');
  25.         $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.\'');
  26.         $this->addSql('ALTER TABLE channel_setting_coefficients ADD CONSTRAINT FK_A1A3E886727ACA70 FOREIGN KEY (parent_id) REFERENCES channel_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  27.         $this->addSql('ALTER TABLE channel_setting_coefficients ADD CONSTRAINT FK_A1A3E8863D3D2749 FOREIGN KEY (children_id) REFERENCES channel_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  28.         $this->addSql('ALTER TABLE channel_settings ADD recipe_id INT DEFAULT NULL');
  29.         $this->addSql('ALTER TABLE channel_settings ADD name VARCHAR(255) DEFAULT NULL');
  30.         $this->addSql('ALTER TABLE channel_settings ADD number INT DEFAULT NULL');
  31.         $this->addSql('ALTER TABLE channel_settings ADD is_average_weighted BOOLEAN DEFAULT \'false\' NOT NULL');
  32.         $this->addSql('ALTER TABLE channel_settings ALTER channel_id DROP NOT NULL');
  33.         $this->addSql('COMMENT ON COLUMN channel_settings.name IS \'Channel name.\'');
  34.         $this->addSql('COMMENT ON COLUMN channel_settings.number IS \'Channel number.\'');
  35.         $this->addSql('COMMENT ON COLUMN channel_settings.is_average_weighted IS \'Is average weighted.\'');
  36.         $this->addSql('ALTER TABLE channel_settings ADD CONSTRAINT FK_92F5D36C59D8A214 FOREIGN KEY (recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  37.         $this->addSql('CREATE INDEX IDX_92F5D36C59D8A214 ON channel_settings (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('DROP SEQUENCE channel_setting_coefficients_id_seq CASCADE');
  45.         $this->addSql('DROP TABLE channel_setting_coefficients');
  46.         $this->addSql('ALTER TABLE channel_settings DROP CONSTRAINT FK_92F5D36C59D8A214');
  47.         $this->addSql('DROP INDEX IDX_92F5D36C59D8A214');
  48.         $this->addSql('ALTER TABLE channel_settings DROP recipe_id');
  49.         $this->addSql('ALTER TABLE channel_settings DROP name');
  50.         $this->addSql('ALTER TABLE channel_settings DROP number');
  51.         $this->addSql('ALTER TABLE channel_settings DROP is_average_weighted');
  52.         $this->addSql('ALTER TABLE channel_settings ALTER channel_id SET NOT NULL');
  53.     }
  54. }