Conditions | 17 |
Paths | > 20000 |
Total Lines | 83 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
19 | public function up(Schema $schema): void |
||
20 | { |
||
21 | // Disable foreign key checks to prevent issues during migration |
||
22 | $this->addSql('SET FOREIGN_KEY_CHECKS = 0;'); |
||
23 | |||
24 | // Drop foreign keys from the specified tables, only if the table exists |
||
25 | if ($schema->hasTable('page__snapshot')) { |
||
26 | $this->addSql('ALTER TABLE page__snapshot DROP FOREIGN KEY IF EXISTS FK_3963EF9AC4663E4;'); |
||
27 | $this->addSql('ALTER TABLE page__snapshot DROP FOREIGN KEY IF EXISTS FK_3963EF9AF6BD1646;'); |
||
28 | } |
||
29 | |||
30 | if ($schema->hasTable('classification__collection')) { |
||
31 | $this->addSql('ALTER TABLE classification__collection DROP FOREIGN KEY IF EXISTS FK_A406B56AE25D857E;'); |
||
32 | $this->addSql('ALTER TABLE classification__collection DROP FOREIGN KEY IF EXISTS FK_A406B56AEA9FDD75;'); |
||
33 | } |
||
34 | |||
35 | if ($schema->hasTable('faq_question')) { |
||
36 | $this->addSql('ALTER TABLE faq_question DROP FOREIGN KEY IF EXISTS FK_4A55B05912469DE2;'); |
||
37 | } |
||
38 | |||
39 | if ($schema->hasTable('page__page')) { |
||
40 | $this->addSql('ALTER TABLE page__page DROP FOREIGN KEY IF EXISTS FK_2FAE39ED727ACA70;'); |
||
41 | $this->addSql('ALTER TABLE page__page DROP FOREIGN KEY IF EXISTS FK_2FAE39EDF6BD1646;'); |
||
42 | $this->addSql('ALTER TABLE page__page DROP FOREIGN KEY IF EXISTS FK_2FAE39ED158E0B66;'); |
||
43 | } |
||
44 | |||
45 | if ($schema->hasTable('page__bloc')) { |
||
46 | $this->addSql('ALTER TABLE page__bloc DROP FOREIGN KEY IF EXISTS FK_FCDC1A97727ACA70;'); |
||
47 | $this->addSql('ALTER TABLE page__bloc DROP FOREIGN KEY IF EXISTS FK_FCDC1A97C4663E4;'); |
||
48 | } |
||
49 | |||
50 | if ($schema->hasTable('timeline__timeline')) { |
||
51 | $this->addSql('ALTER TABLE timeline__timeline DROP FOREIGN KEY IF EXISTS FK_FFBC6AD523EDC87;'); |
||
52 | $this->addSql('ALTER TABLE timeline__timeline DROP FOREIGN KEY IF EXISTS FK_FFBC6AD59D32F035;'); |
||
53 | } |
||
54 | |||
55 | if ($schema->hasTable('plugin_bbb_room')) { |
||
56 | $this->addSql('ALTER TABLE plugin_bbb_room DROP FOREIGN KEY IF EXISTS plugin_bbb_room_ibfk_2;'); |
||
57 | $this->addSql('ALTER TABLE plugin_bbb_room DROP FOREIGN KEY IF EXISTS plugin_bbb_room_ibfk_1;'); |
||
58 | } |
||
59 | |||
60 | if ($schema->hasTable('classification__category')) { |
||
61 | $this->addSql('ALTER TABLE classification__category DROP FOREIGN KEY IF EXISTS FK_43629B36727ACA70;'); |
||
62 | $this->addSql('ALTER TABLE classification__category DROP FOREIGN KEY IF EXISTS FK_43629B36E25D857E;'); |
||
63 | $this->addSql('ALTER TABLE classification__category DROP FOREIGN KEY IF EXISTS FK_43629B36EA9FDD75;'); |
||
64 | } |
||
65 | |||
66 | if ($schema->hasTable('faq_question_translation')) { |
||
67 | $this->addSql('ALTER TABLE faq_question_translation DROP FOREIGN KEY IF EXISTS FK_C2D1A2C2AC5D3;'); |
||
68 | } |
||
69 | |||
70 | if ($schema->hasTable('classification__tag')) { |
||
71 | $this->addSql('ALTER TABLE classification__tag DROP FOREIGN KEY IF EXISTS FK_CA57A1C7E25D857E;'); |
||
72 | } |
||
73 | |||
74 | if ($schema->hasTable('faq_category_translation')) { |
||
75 | $this->addSql('ALTER TABLE faq_category_translation DROP FOREIGN KEY IF EXISTS FK_5493B0FC2C2AC5D3;'); |
||
76 | } |
||
77 | |||
78 | if ($schema->hasTable('timeline__action_component')) { |
||
79 | $this->addSql('ALTER TABLE timeline__action_component DROP FOREIGN KEY IF EXISTS FK_6ACD1B16E2ABAFFF;'); |
||
80 | $this->addSql('ALTER TABLE timeline__action_component DROP FOREIGN KEY IF EXISTS FK_6ACD1B169D32F035;'); |
||
81 | } |
||
82 | |||
83 | if ($schema->hasTable('media__media')) { |
||
84 | $this->addSql('ALTER TABLE media__media DROP FOREIGN KEY IF EXISTS FK_5C6DD74E12469DE2;'); |
||
85 | } |
||
86 | |||
87 | if ($schema->hasTable('contact_category_translation')) { |
||
88 | $this->addSql('ALTER TABLE contact_category_translation DROP FOREIGN KEY IF EXISTS FK_3E770F302C2AC5D3;'); |
||
89 | } |
||
90 | |||
91 | if ($schema->hasTable('media__gallery_media')) { |
||
92 | $this->addSql('ALTER TABLE media__gallery_media DROP FOREIGN KEY IF EXISTS FK_80D4C541EA9FDD75;'); |
||
93 | $this->addSql('ALTER TABLE media__gallery_media DROP FOREIGN KEY IF EXISTS FK_80D4C5414E7AF8F;'); |
||
94 | } |
||
95 | |||
96 | if ($schema->hasTable('c_blog')) { |
||
97 | $this->addSql('ALTER TABLE c_blog DROP FOREIGN KEY IF EXISTS FK_64B00A121BAD783F;'); |
||
98 | } |
||
99 | |||
100 | // Re-enable foreign key checks |
||
101 | $this->addSql('SET FOREIGN_KEY_CHECKS = 1;'); |
||
102 | } |
||
106 |