Code Duplication    Length = 24-33 lines in 11 locations

src/SWP/Bundle/CoreBundle/Migrations/2019/03/Version20190301132129.php 1 location

@@ 13-36 (lines=24) @@
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20190301132129 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('CREATE TABLE swp_article_related (id SERIAL NOT NULL, article_id INT DEFAULT NULL, relates_to_id INT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
21
        $this->addSql('CREATE INDEX IDX_518726317294869C ON swp_article_related (article_id)');
22
        $this->addSql('CREATE INDEX IDX_51872631E2CD0E0E ON swp_article_related (relates_to_id)');
23
        $this->addSql('ALTER TABLE swp_article_related ADD CONSTRAINT FK_518726317294869C FOREIGN KEY (article_id) REFERENCES swp_article (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
24
        $this->addSql('ALTER TABLE swp_article_related ADD CONSTRAINT FK_51872631E2CD0E0E FOREIGN KEY (relates_to_id) REFERENCES swp_article (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
25
        $this->addSql('ALTER TABLE swp_item_groups ADD type VARCHAR(255) DEFAULT NULL');
26
    }
27
28
    public function down(Schema $schema): void
29
    {
30
        // this down() migration is auto-generated, please modify it to your needs
31
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
32
33
        $this->addSql('DROP TABLE swp_article_related');
34
        $this->addSql('ALTER TABLE swp_item_groups DROP type');
35
    }
36
}
37

src/SWP/Bundle/CoreBundle/Migrations/2019/04/Version20190401123245.php 1 location

@@ 13-36 (lines=24) @@
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20190401123245 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('ALTER TABLE swp_article_media ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
21
        $this->addSql('ALTER TABLE swp_article_media ALTER created_at DROP DEFAULT');
22
        $this->addSql('ALTER TABLE swp_article_media ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
23
        $this->addSql('ALTER TABLE swp_article_media ALTER updated_at DROP DEFAULT');
24
    }
25
26
    public function down(Schema $schema): void
27
    {
28
        // this down() migration is auto-generated, please modify it to your needs
29
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
30
31
        $this->addSql('ALTER TABLE swp_article_media ALTER created_at TYPE DATE');
32
        $this->addSql('ALTER TABLE swp_article_media ALTER created_at DROP DEFAULT');
33
        $this->addSql('ALTER TABLE swp_article_media ALTER updated_at TYPE DATE');
34
        $this->addSql('ALTER TABLE swp_article_media ALTER updated_at DROP DEFAULT');
35
    }
36
}
37

src/SWP/Bundle/CoreBundle/Migrations/2019/04/Version20190403081555.php 1 location

@@ 13-45 (lines=33) @@
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20190403081555 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('
21
            UPDATE 
22
                swp_article 
23
            SET 
24
                feature_media = NULL
25
            WHERE 
26
                  feature_media IN (
27
                    SELECT id FROM swp_article_media WHERE deleted_at IS NOT NULL 
28
                  )
29
        ');
30
        $this->addSql('DELETE FROM swp_article_media WHERE deleted_at IS NOT NULL');
31
        $this->addSql('ALTER TABLE swp_article_media DROP deleted_at');
32
        $this->addSql('ALTER TABLE swp_article_media ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
33
        $this->addSql('ALTER TABLE swp_article_media ALTER updated_at DROP DEFAULT');
34
    }
35
36
    public function down(Schema $schema): void
37
    {
38
        // this down() migration is auto-generated, please modify it to your needs
39
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
40
41
        $this->addSql('ALTER TABLE swp_article_media ADD deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
42
        $this->addSql('ALTER TABLE swp_article_media ALTER updated_at TYPE DATE');
43
        $this->addSql('ALTER TABLE swp_article_media ALTER updated_at DROP DEFAULT');
44
    }
45
}
46

src/SWP/Bundle/CoreBundle/Migrations/2019/05/Version20190510112541.php 1 location

@@ 13-36 (lines=24) @@
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20190510112541 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('ALTER TABLE swp_package_preview_token DROP CONSTRAINT FK_AD1CA87234ECB4E6');
21
        $this->addSql('ALTER TABLE swp_package_preview_token ADD CONSTRAINT FK_AD1CA87234ECB4E6 FOREIGN KEY (route_id) REFERENCES swp_route (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
22
        $this->addSql('ALTER TABLE swp_publish_destination DROP CONSTRAINT FK_8C71004A34ECB4E6');
23
        $this->addSql('ALTER TABLE swp_publish_destination ADD CONSTRAINT FK_8C71004A34ECB4E6 FOREIGN KEY (route_id) REFERENCES swp_route (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
24
    }
25
26
    public function down(Schema $schema): void
27
    {
28
        // this down() migration is auto-generated, please modify it to your needs
29
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
30
31
        $this->addSql('ALTER TABLE swp_package_preview_token DROP CONSTRAINT fk_ad1ca87234ecb4e6');
32
        $this->addSql('ALTER TABLE swp_package_preview_token ADD CONSTRAINT fk_ad1ca87234ecb4e6 FOREIGN KEY (route_id) REFERENCES swp_route (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
33
        $this->addSql('ALTER TABLE swp_publish_destination DROP CONSTRAINT fk_8c71004a34ecb4e6');
34
        $this->addSql('ALTER TABLE swp_publish_destination ADD CONSTRAINT fk_8c71004a34ecb4e6 FOREIGN KEY (route_id) REFERENCES swp_route (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
35
    }
36
}
37

src/SWP/Bundle/CoreBundle/Migrations/2020/04/Version20200406121345.php 1 location

@@ 13-36 (lines=24) @@
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20200406121345 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('ALTER TABLE swp_article_author DROP CONSTRAINT FK_37796667294869C');
21
        $this->addSql('ALTER TABLE swp_article_author DROP CONSTRAINT FK_3779666F675F31B');
22
        $this->addSql('ALTER TABLE swp_article_author ADD CONSTRAINT FK_37796667294869C FOREIGN KEY (article_id) REFERENCES swp_article (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
23
        $this->addSql('ALTER TABLE swp_article_author ADD CONSTRAINT FK_3779666F675F31B FOREIGN KEY (author_id) REFERENCES swp_author (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
24
    }
25
26
    public function down(Schema $schema): void
27
    {
28
        // this down() migration is auto-generated, please modify it to your needs
29
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
30
31
        $this->addSql('ALTER TABLE swp_article_author DROP CONSTRAINT fk_37796667294869c');
32
        $this->addSql('ALTER TABLE swp_article_author DROP CONSTRAINT fk_3779666f675f31b');
33
        $this->addSql('ALTER TABLE swp_article_author ADD CONSTRAINT fk_37796667294869c FOREIGN KEY (article_id) REFERENCES swp_article (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
34
        $this->addSql('ALTER TABLE swp_article_author ADD CONSTRAINT fk_3779666f675f31b FOREIGN KEY (author_id) REFERENCES swp_author (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
35
    }
36
}
37

src/SWP/Bundle/CoreBundle/Migrations/Version20170222142920.php 1 location

@@ 11-41 (lines=31) @@
8
/**
9
 * Auto-generated Migration: Please modify to your needs!
10
 */
11
class Version20170222142920 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('ALTER TABLE swp_item ADD evolved_from VARCHAR(255) DEFAULT NULL');
22
        $this->addSql('ALTER TABLE swp_package ADD evolved_from VARCHAR(255) DEFAULT NULL');
23
        $this->addSql('ALTER TABLE swp_article ADD code VARCHAR(255) DEFAULT NULL');
24
        $this->addSql('UPDATE swp_article SET code = md5(random()::text)');
25
        $this->addSql('UPDATE swp_article a SET code = p.guid FROM swp_package p WHERE a.slug = LOWER(replace(p.slugline, \' \', \'-\'))');
26
        $this->addSql('ALTER TABLE swp_article ALTER COLUMN code SET NOT NULL');
27
    }
28
29
    /**
30
     * @param Schema $schema
31
     */
32
    public function down(Schema $schema)
33
    {
34
        // this down() migration is auto-generated, please modify it to your needs
35
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
36
37
        $this->addSql('ALTER TABLE swp_item DROP evolved_from');
38
        $this->addSql('ALTER TABLE swp_package DROP evolved_from');
39
        $this->addSql('ALTER TABLE swp_article DROP code');
40
    }
41
}
42

src/SWP/Bundle/CoreBundle/Migrations/Version20170908085421.php 1 location

@@ 11-40 (lines=30) @@
8
/**
9
 * Auto-generated Migration: Please modify to your needs!
10
 */
11
class Version20170908085421 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('ALTER TABLE swp_article_sources DROP CONSTRAINT FK_E38D33537294869C');
22
        $this->addSql('ALTER TABLE swp_article_sources DROP CONSTRAINT FK_E38D3353953C1C61');
23
        $this->addSql('ALTER TABLE swp_article_sources ADD CONSTRAINT FK_E38D33537294869C FOREIGN KEY (article_id) REFERENCES swp_article (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
24
        $this->addSql('ALTER TABLE swp_article_sources ADD CONSTRAINT FK_E38D3353953C1C61 FOREIGN KEY (source_id) REFERENCES swp_article_source (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
25
    }
26
27
    /**
28
     * @param Schema $schema
29
     */
30
    public function down(Schema $schema)
31
    {
32
        // this down() migration is auto-generated, please modify it to your needs
33
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
34
35
        $this->addSql('ALTER TABLE swp_article_sources DROP CONSTRAINT fk_e38d33537294869c');
36
        $this->addSql('ALTER TABLE swp_article_sources DROP CONSTRAINT fk_e38d3353953c1c61');
37
        $this->addSql('ALTER TABLE swp_article_sources ADD CONSTRAINT fk_e38d33537294869c FOREIGN KEY (article_id) REFERENCES swp_article (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
38
        $this->addSql('ALTER TABLE swp_article_sources ADD CONSTRAINT fk_e38d3353953c1c61 FOREIGN KEY (source_id) REFERENCES swp_article_source (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
39
    }
40
}
41

src/SWP/Bundle/CoreBundle/Migrations/Version20171215172352.php 1 location

@@ 11-40 (lines=30) @@
8
/**
9
 * Auto-generated Migration: Please modify to your needs!
10
 */
11
class Version20171215172352 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('ALTER TABLE swp_article_events ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL');
22
        $this->addSql('ALTER TABLE swp_article_events ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
23
        $this->addSql('ALTER TABLE swp_article_statistics ADD created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL');
24
        $this->addSql('ALTER TABLE swp_article_statistics ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
25
    }
26
27
    /**
28
     * @param Schema $schema
29
     */
30
    public function down(Schema $schema)
31
    {
32
        // this down() migration is auto-generated, please modify it to your needs
33
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
34
35
        $this->addSql('ALTER TABLE swp_article_events DROP created_at');
36
        $this->addSql('ALTER TABLE swp_article_events DROP updated_at');
37
        $this->addSql('ALTER TABLE swp_article_statistics DROP created_at');
38
        $this->addSql('ALTER TABLE swp_article_statistics DROP updated_at');
39
    }
40
}
41

src/SWP/Bundle/CoreBundle/Migrations/Version20180130132921.php 1 location

@@ 13-37 (lines=25) @@
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
class Version20180130132921 extends AbstractMigration
14
{
15
    public function up(Schema $schema)
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('ALTER TABLE swp_item ADD extra TEXT DEFAULT NULL');
21
        $this->addSql('COMMENT ON COLUMN swp_item.extra IS \'(DC2Type:array)\'');
22
        $this->addSql('ALTER TABLE swp_package ADD extra TEXT DEFAULT NULL');
23
        $this->addSql('COMMENT ON COLUMN swp_package.extra IS \'(DC2Type:array)\'');
24
        $this->addSql('ALTER TABLE swp_article ADD extra TEXT DEFAULT \'a:0:{}\'');
25
        $this->addSql('COMMENT ON COLUMN swp_article.extra IS \'(DC2Type:array)\'');
26
    }
27
28
    public function down(Schema $schema)
29
    {
30
        // this down() migration is auto-generated, please modify it to your needs
31
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
32
33
        $this->addSql('ALTER TABLE swp_item DROP extra');
34
        $this->addSql('ALTER TABLE swp_package DROP extra');
35
        $this->addSql('ALTER TABLE swp_article DROP extra');
36
    }
37
}
38

src/SWP/Bundle/CoreBundle/Migrations/Version20180307144819.php 1 location

@@ 13-38 (lines=26) @@
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
class Version20180307144819 extends AbstractMigration
14
{
15
    public function up(Schema $schema)
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('CREATE SEQUENCE swp_publish_destination_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
21
        $this->addSql('CREATE TABLE swp_publish_destination (id INT NOT NULL, tenant_id INT DEFAULT NULL, route_id INT DEFAULT NULL, organization_id INT NOT NULL, fbia BOOLEAN NOT NULL, published BOOLEAN NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
22
        $this->addSql('CREATE INDEX IDX_8C71004A9033212A ON swp_publish_destination (tenant_id)');
23
        $this->addSql('CREATE INDEX IDX_8C71004A34ECB4E6 ON swp_publish_destination (route_id)');
24
        $this->addSql('CREATE INDEX IDX_8C71004A32C8A3DE ON swp_publish_destination (organization_id)');
25
        $this->addSql('ALTER TABLE swp_publish_destination ADD CONSTRAINT FK_8C71004A9033212A FOREIGN KEY (tenant_id) REFERENCES swp_tenant (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
26
        $this->addSql('ALTER TABLE swp_publish_destination ADD CONSTRAINT FK_8C71004A34ECB4E6 FOREIGN KEY (route_id) REFERENCES swp_route (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
27
        $this->addSql('ALTER TABLE swp_publish_destination ADD CONSTRAINT FK_8C71004A32C8A3DE FOREIGN KEY (organization_id) REFERENCES swp_organization (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
28
    }
29
30
    public function down(Schema $schema)
31
    {
32
        // this down() migration is auto-generated, please modify it to your needs
33
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
34
35
        $this->addSql('DROP SEQUENCE swp_publish_destination_id_seq CASCADE');
36
        $this->addSql('DROP TABLE swp_publish_destination');
37
    }
38
}
39

src/SWP/Bundle/CoreBundle/Migrations/2021/03/Version20210330074519.php 1 location

@@ 13-36 (lines=24) @@
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20210330074519 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('ALTER TABLE swp_redirect_route DROP CONSTRAINT FK_8681EEEE397EC969');
21
        $this->addSql('DROP INDEX idx_8681eeee397ec969');
22
        $this->addSql('ALTER TABLE swp_redirect_route ADD CONSTRAINT FK_8681EEEE397EC969 FOREIGN KEY (route_source_id) REFERENCES swp_route (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
23
        $this->addSql('CREATE UNIQUE INDEX UNIQ_8681EEEE397EC969 ON swp_redirect_route (route_source_id)');
24
    }
25
26
    public function down(Schema $schema): void
27
    {
28
        // this down() migration is auto-generated, please modify it to your needs
29
        $this->abortIf('postgresql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'postgresql\'.');
30
31
        $this->addSql('ALTER TABLE swp_redirect_route DROP CONSTRAINT fk_8681eeee397ec969');
32
        $this->addSql('DROP INDEX UNIQ_8681EEEE397EC969');
33
        $this->addSql('ALTER TABLE swp_redirect_route ADD CONSTRAINT fk_8681eeee397ec969 FOREIGN KEY (route_source_id) REFERENCES swp_route (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
34
        $this->addSql('CREATE INDEX idx_8681eeee397ec969 ON swp_redirect_route (route_source_id)');
35
    }
36
}
37