migrations/Version20200424090224.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 Version20200424090224 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 line_type_groups_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  20.         $this->addSql('CREATE SEQUENCE line_types_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  21.         $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))');
  22.         $this->addSql('CREATE INDEX IDX_E4DCD2AB9395C3F3 ON line_type_groups (customer_id)');
  23.         $this->addSql('COMMENT ON COLUMN line_type_groups.name IS \'Group name.\'');
  24.         $this->addSql('COMMENT ON COLUMN line_type_groups.created_at IS \'Date of the entity creation. Should be fixed.\'');
  25.         $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.\'');
  26.         $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))');
  27.         $this->addSql('CREATE INDEX IDX_A6B4AEB3AB40EAD2 ON line_types (line_type_group_id)');
  28.         $this->addSql('COMMENT ON COLUMN line_types.thickness IS \'Thickness.\'');
  29.         $this->addSql('COMMENT ON COLUMN line_types.colour IS \'Colour.\'');
  30.         $this->addSql('COMMENT ON COLUMN line_types.created_at IS \'Date of the entity creation. Should be fixed.\'');
  31.         $this->addSql('COMMENT ON COLUMN line_types.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
  32.         $this->addSql('ALTER TABLE line_type_groups ADD CONSTRAINT FK_E4DCD2AB9395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  33.         $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');
  34.     }
  35.     public function down(Schema $schema) : void
  36.     {
  37.         // this down() migration is auto-generated, please modify it to your needs
  38.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  39.         $this->addSql('CREATE SCHEMA public');
  40.         $this->addSql('ALTER TABLE line_types DROP CONSTRAINT FK_A6B4AEB3AB40EAD2');
  41.         $this->addSql('DROP SEQUENCE line_type_groups_id_seq CASCADE');
  42.         $this->addSql('DROP SEQUENCE line_types_id_seq CASCADE');
  43.         $this->addSql('CREATE SEQUENCE data_sample_added_queue_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
  44.         $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))');
  45.         $this->addSql('CREATE INDEX idx_bc650a7cfb7336f0 ON data_sample_added_queue (queue_name)');
  46.         $this->addSql('CREATE INDEX idx_bc650a7c16ba31db ON data_sample_added_queue (delivered_at)');
  47.         $this->addSql('CREATE INDEX idx_bc650a7ce3bd61ce ON data_sample_added_queue (available_at)');
  48.         $this->addSql('DROP TABLE line_type_groups');
  49.         $this->addSql('DROP TABLE line_types');
  50.     }
  51. }