<?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 Version20200424090224 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 line_type_groups_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE line_types_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE line_type_groups (id INT NOT NULL, customer_id INT DEFAULT NULL, name TEXT 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_E4DCD2AB9395C3F3 ON line_type_groups (customer_id)');
$this->addSql('COMMENT ON COLUMN line_type_groups.name IS \'Group name.\'');
$this->addSql('COMMENT ON COLUMN line_type_groups.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN line_type_groups.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('CREATE TABLE line_types (id INT NOT NULL, line_type_group_id INT DEFAULT NULL, thickness INT NOT NULL, colour TEXT 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_A6B4AEB3AB40EAD2 ON line_types (line_type_group_id)');
$this->addSql('COMMENT ON COLUMN line_types.thickness IS \'Thickness.\'');
$this->addSql('COMMENT ON COLUMN line_types.colour IS \'Colour.\'');
$this->addSql('COMMENT ON COLUMN line_types.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN line_types.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('ALTER TABLE line_type_groups ADD CONSTRAINT FK_E4DCD2AB9395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE line_types ADD CONSTRAINT FK_A6B4AEB3AB40EAD2 FOREIGN KEY (line_type_group_id) REFERENCES line_type_groups (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
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 line_types DROP CONSTRAINT FK_A6B4AEB3AB40EAD2');
$this->addSql('DROP SEQUENCE line_type_groups_id_seq CASCADE');
$this->addSql('DROP SEQUENCE line_types_id_seq CASCADE');
$this->addSql('CREATE SEQUENCE data_sample_added_queue_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE data_sample_added_queue (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX idx_bc650a7cfb7336f0 ON data_sample_added_queue (queue_name)');
$this->addSql('CREATE INDEX idx_bc650a7c16ba31db ON data_sample_added_queue (delivered_at)');
$this->addSql('CREATE INDEX idx_bc650a7ce3bd61ce ON data_sample_added_queue (available_at)');
$this->addSql('DROP TABLE line_type_groups');
$this->addSql('DROP TABLE line_types');
}
}