| @@ 13-102 (lines=90) @@ | ||
| 10 | /** |
|
| 11 | * Auto-generated Migration: Please modify to your needs! |
|
| 12 | */ |
|
| 13 | final class Version20191113081727 extends AbstractMigration |
|
| 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('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
| 19 | ||
| 20 | $this->addSql('DROP SEQUENCE swp_article_events_id_seq CASCADE'); |
|
| 21 | $this->addSql('DROP TABLE swp_article_events'); |
|
| 22 | $this->addSql('ALTER TABLE swp_author ALTER biography TYPE TEXT'); |
|
| 23 | $this->addSql('ALTER TABLE swp_author ALTER biography DROP DEFAULT'); |
|
| 24 | $this->addSql('ALTER TABLE swp_author ALTER biography TYPE TEXT'); |
|
| 25 | $this->addSql('ALTER TABLE swp_package ALTER genre TYPE TEXT'); |
|
| 26 | $this->addSql('ALTER TABLE swp_package ALTER genre DROP DEFAULT'); |
|
| 27 | $this->addSql('DROP INDEX swp_article_slug_null_deleted_at_idx'); |
|
| 28 | $this->addSql('DROP INDEX swp_article_slug_not_null_deleted_at_idx'); |
|
| 29 | $this->addSql('CREATE UNIQUE INDEX swp_article_slug_null_deleted_at_idx ON swp_article ( |
|
| 30 | slug, tenant_code, organization_id |
|
| 31 | ) |
|
| 32 | WHERE |
|
| 33 | deleted_at IS NULL'); |
|
| 34 | $this->addSql('CREATE UNIQUE INDEX swp_article_slug_not_null_deleted_at_idx ON swp_article ( |
|
| 35 | slug, tenant_code, organization_id, |
|
| 36 | deleted_at |
|
| 37 | ) |
|
| 38 | WHERE |
|
| 39 | deleted_at IS NOT NULL'); |
|
| 40 | $this->addSql('ALTER TABLE swp_image ALTER length TYPE DOUBLE PRECISION'); |
|
| 41 | $this->addSql('ALTER TABLE swp_image ALTER length DROP DEFAULT'); |
|
| 42 | } |
|
| 43 | ||
| 44 | public function down(Schema $schema): void |
|
| 45 | { |
|
| 46 | // this down() migration is auto-generated, please modify it to your needs |
|
| 47 | $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
| 48 | ||
| 49 | $this->addSql('CREATE SEQUENCE swp_article_events_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
| 50 | $this->addSql('CREATE TABLE swp_article_events ( |
|
| 51 | id INT NOT NULL, |
|
| 52 | article_statistics_id INT NOT NULL, |
|
| 53 | route_id INT DEFAULT NULL, |
|
| 54 | article_id INT DEFAULT NULL, |
|
| 55 | action VARCHAR(255) DEFAULT NULL, |
|
| 56 | impression_type VARCHAR(255) DEFAULT NULL, |
|
| 57 | tenant_code VARCHAR(255) NOT NULL, |
|
| 58 | created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, |
|
| 59 | updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, |
|
| 60 | page_view_source VARCHAR(255) DEFAULT NULL, |
|
| 61 | PRIMARY KEY(id) |
|
| 62 | )'); |
|
| 63 | $this->addSql('CREATE INDEX idx_ed5f19e434ecb4e6 ON swp_article_events (route_id)'); |
|
| 64 | $this->addSql('CREATE INDEX idx_ed5f19e47294869c ON swp_article_events (article_id)'); |
|
| 65 | $this->addSql('CREATE INDEX idx_ed5f19e41dfe7a17 ON swp_article_events (article_statistics_id)'); |
|
| 66 | $this->addSql('CREATE INDEX idx_article_events ON swp_article_events ( |
|
| 67 | article_statistics_id, tenant_code, |
|
| 68 | created_at |
|
| 69 | )'); |
|
| 70 | $this->addSql('ALTER TABLE |
|
| 71 | swp_article_events |
|
| 72 | ADD |
|
| 73 | CONSTRAINT fk_ed5f19e41dfe7a17 FOREIGN KEY (article_statistics_id) REFERENCES swp_article_statistics (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
| 74 | $this->addSql('ALTER TABLE |
|
| 75 | swp_article_events |
|
| 76 | ADD |
|
| 77 | CONSTRAINT fk_ed5f19e434ecb4e6 FOREIGN KEY (route_id) REFERENCES swp_route (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
| 78 | $this->addSql('ALTER TABLE |
|
| 79 | swp_article_events |
|
| 80 | ADD |
|
| 81 | CONSTRAINT fk_ed5f19e47294869c FOREIGN KEY (article_id) REFERENCES swp_article (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
| 82 | $this->addSql('ALTER TABLE swp_package ALTER genre TYPE TEXT'); |
|
| 83 | $this->addSql('ALTER TABLE swp_package ALTER genre DROP DEFAULT'); |
|
| 84 | $this->addSql('ALTER TABLE swp_image ALTER length TYPE NUMERIC(10, 0)'); |
|
| 85 | $this->addSql('ALTER TABLE swp_image ALTER length DROP DEFAULT'); |
|
| 86 | $this->addSql('DROP INDEX swp_article_slug_not_null_deleted_at_idx'); |
|
| 87 | $this->addSql('DROP INDEX swp_article_slug_null_deleted_at_idx'); |
|
| 88 | $this->addSql('CREATE UNIQUE INDEX swp_article_slug_not_null_deleted_at_idx ON swp_article ( |
|
| 89 | slug, tenant_code, organization_id, |
|
| 90 | deleted_at |
|
| 91 | ) |
|
| 92 | WHERE |
|
| 93 | (deleted_at IS NOT NULL)'); |
|
| 94 | $this->addSql('CREATE UNIQUE INDEX swp_article_slug_null_deleted_at_idx ON swp_article ( |
|
| 95 | slug, tenant_code, organization_id |
|
| 96 | ) |
|
| 97 | WHERE |
|
| 98 | (deleted_at IS NULL)'); |
|
| 99 | $this->addSql('ALTER TABLE swp_author ALTER biography TYPE VARCHAR(460)'); |
|
| 100 | $this->addSql('ALTER TABLE swp_author ALTER biography DROP DEFAULT'); |
|
| 101 | } |
|
| 102 | } |
|
| 103 | ||
| @@ 11-64 (lines=54) @@ | ||
| 8 | /** |
|
| 9 | * Auto-generated Migration: Please modify to your needs! |
|
| 10 | */ |
|
| 11 | class Version20170908083733 extends AbstractMigration |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @param Schema $schema |
|
| 15 | */ |
|
| 16 | public function up(Schema $schema) |
|
| 17 | { |
|
| 18 | // this up() migration is auto-generated, please modify it to your needs |
|
| 19 | $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
| 20 | ||
| 21 | $this->addSql('CREATE SEQUENCE swp_event_category_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
| 22 | $this->addSql('CREATE SEQUENCE swp_event_date_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
| 23 | $this->addSql('CREATE SEQUENCE swp_event_location_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
| 24 | $this->addSql('CREATE SEQUENCE swp_event_occur_status_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
| 25 | $this->addSql('CREATE SEQUENCE swp_event_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); |
|
| 26 | $this->addSql('CREATE TABLE swp_event_category (id INT NOT NULL, event_id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, subject VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
| 27 | $this->addSql('CREATE INDEX IDX_94BF293F71F7E88B ON swp_event_category (event_id)'); |
|
| 28 | $this->addSql('CREATE TABLE swp_event_date (id INT NOT NULL, start_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, end_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, tz VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
| 29 | $this->addSql('CREATE TABLE swp_event_location (id INT NOT NULL, event_id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
| 30 | $this->addSql('CREATE INDEX IDX_CC6DB93571F7E88B ON swp_event_location (event_id)'); |
|
| 31 | $this->addSql('CREATE TABLE swp_event_occur_status (id INT NOT NULL, name VARCHAR(255) NOT NULL, qcode VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); |
|
| 32 | $this->addSql('CREATE TABLE swp_event (id INT NOT NULL, dates_id INT DEFAULT NULL, occur_status_id INT DEFAULT NULL, etag VARCHAR(255) NOT NULL, guid VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, version INT DEFAULT NULL, ingest_id VARCHAR(255) DEFAULT NULL, recurrence_id VARCHAR(255) DEFAULT NULL, original_creator VARCHAR(255) NOT NULL, version_creator VARCHAR(255) DEFAULT NULL, ingest_provider VARCHAR(255) DEFAULT NULL, original_source VARCHAR(255) DEFAULT NULL, ingest_provider_sequence VARCHAR(255) DEFAULT NULL, definition_short VARCHAR(255) DEFAULT NULL, definition_long VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
|
| 33 | $this->addSql('CREATE UNIQUE INDEX UNIQ_658EE4843DA992C3 ON swp_event (dates_id)'); |
|
| 34 | $this->addSql('CREATE UNIQUE INDEX UNIQ_658EE4845DA64DFB ON swp_event (occur_status_id)'); |
|
| 35 | $this->addSql('ALTER TABLE swp_event_category ADD CONSTRAINT FK_94BF293F71F7E88B FOREIGN KEY (event_id) REFERENCES swp_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
| 36 | $this->addSql('ALTER TABLE swp_event_location ADD CONSTRAINT FK_CC6DB93571F7E88B FOREIGN KEY (event_id) REFERENCES swp_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
| 37 | $this->addSql('ALTER TABLE swp_event ADD CONSTRAINT FK_658EE4843DA992C3 FOREIGN KEY (dates_id) REFERENCES swp_event_date (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
| 38 | $this->addSql('ALTER TABLE swp_event ADD CONSTRAINT FK_658EE4845DA64DFB FOREIGN KEY (occur_status_id) REFERENCES swp_event_occur_status (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @param Schema $schema |
|
| 43 | */ |
|
| 44 | public function down(Schema $schema) |
|
| 45 | { |
|
| 46 | // this down() migration is auto-generated, please modify it to your needs |
|
| 47 | $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.'); |
|
| 48 | ||
| 49 | $this->addSql('ALTER TABLE swp_event DROP CONSTRAINT FK_658EE4843DA992C3'); |
|
| 50 | $this->addSql('ALTER TABLE swp_event DROP CONSTRAINT FK_658EE4845DA64DFB'); |
|
| 51 | $this->addSql('ALTER TABLE swp_event_category DROP CONSTRAINT FK_94BF293F71F7E88B'); |
|
| 52 | $this->addSql('ALTER TABLE swp_event_location DROP CONSTRAINT FK_CC6DB93571F7E88B'); |
|
| 53 | $this->addSql('DROP SEQUENCE swp_event_category_id_seq CASCADE'); |
|
| 54 | $this->addSql('DROP SEQUENCE swp_event_date_id_seq CASCADE'); |
|
| 55 | $this->addSql('DROP SEQUENCE swp_event_location_id_seq CASCADE'); |
|
| 56 | $this->addSql('DROP SEQUENCE swp_event_occur_status_id_seq CASCADE'); |
|
| 57 | $this->addSql('DROP SEQUENCE swp_event_id_seq CASCADE'); |
|
| 58 | $this->addSql('DROP TABLE swp_event_category'); |
|
| 59 | $this->addSql('DROP TABLE swp_event_date'); |
|
| 60 | $this->addSql('DROP TABLE swp_event_location'); |
|
| 61 | $this->addSql('DROP TABLE swp_event_occur_status'); |
|
| 62 | $this->addSql('DROP TABLE swp_event'); |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||