| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Lines | 58 |
| Ratio | 100 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 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 |