| Conditions | 13 |
| Paths | 4096 |
| Total Lines | 63 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 17 | public function up(Schema $schema): void |
||
| 18 | { |
||
| 19 | $table = $schema->getTable('c_forum_post'); |
||
| 20 | if (!$table->hasIndex('c_id_visible_post_date')) { |
||
| 21 | $this->addSql('CREATE INDEX c_id_visible_post_date ON c_forum_post (c_id, visible, post_date)'); |
||
| 22 | } |
||
| 23 | |||
| 24 | if (false === $table->hasForeignKey('FK_B5BEF559E2904019')) { |
||
| 25 | $this->addSql( |
||
| 26 | 'ALTER TABLE c_forum_post ADD CONSTRAINT FK_B5BEF559E2904019 FOREIGN KEY (thread_id) REFERENCES c_forum_thread (iid)' |
||
| 27 | ); |
||
| 28 | } |
||
| 29 | |||
| 30 | if ($table->hasColumn('poster_name')) { |
||
| 31 | $this->addSql('ALTER TABLE c_forum_post DROP poster_name'); |
||
| 32 | } |
||
| 33 | |||
| 34 | if ($table->hasIndex('poster_id')) { |
||
| 35 | $this->addSql('DROP INDEX poster_id ON c_forum_post;'); |
||
| 36 | } |
||
| 37 | |||
| 38 | if (false === $table->hasForeignKey('FK_B5BEF5595BB66C05')) { |
||
| 39 | $this->addSql('ALTER TABLE c_forum_post ADD CONSTRAINT FK_B5BEF5595BB66C05 FOREIGN KEY (poster_id) REFERENCES user (id);'); |
||
| 40 | $this->addSql('CREATE INDEX IDX_B5BEF5595BB66C05 ON c_forum_post (poster_id)'); |
||
| 41 | } |
||
| 42 | |||
| 43 | $this->addSql('UPDATE c_forum_post SET thread_id = NULL WHERE thread_id NOT IN (SELECT iid FROM c_forum_thread)'); |
||
| 44 | $this->addSql('UPDATE c_forum_thread SET forum_id = NULL WHERE forum_id NOT IN (SELECT iid FROM c_forum_forum)'); |
||
| 45 | $this->addSql('UPDATE c_forum_forum SET forum_category = NULL WHERE forum_category NOT IN (SELECT iid FROM c_forum_category)'); |
||
| 46 | |||
| 47 | $table = $schema->getTable('c_forum_forum'); |
||
| 48 | if (false === $table->hasForeignKey('FK_47A9C9921BF9426')) { |
||
| 49 | $this->addSql( |
||
| 50 | 'ALTER TABLE c_forum_forum ADD CONSTRAINT FK_47A9C9921BF9426 FOREIGN KEY (forum_category) REFERENCES c_forum_category (iid) ON DELETE SET NULL' |
||
| 51 | ); |
||
| 52 | } |
||
| 53 | |||
| 54 | if (false === $table->hasIndex('IDX_47A9C9921BF9426')) { |
||
| 55 | $this->addSql('CREATE INDEX IDX_47A9C9921BF9426 ON c_forum_forum (forum_category)'); |
||
| 56 | } |
||
| 57 | |||
| 58 | if (false === $table->hasForeignKey('FK_47A9C99F2E82C87')) { |
||
| 59 | $this->addSql('ALTER TABLE c_forum_forum ADD CONSTRAINT FK_47A9C99F2E82C87 FOREIGN KEY (forum_last_post) REFERENCES c_forum_post (iid)'); |
||
| 60 | $this->addSql('CREATE INDEX IDX_47A9C99F2E82C87 ON c_forum_forum (forum_last_post);'); |
||
| 61 | } |
||
| 62 | |||
| 63 | $table = $schema->getTable('c_forum_thread'); |
||
| 64 | if (false === $table->hasForeignKey('FK_5DA7884C29CCBAD0')) { |
||
| 65 | $this->addSql('ALTER TABLE c_forum_thread ADD CONSTRAINT FK_5DA7884C29CCBAD0 FOREIGN KEY (forum_id) REFERENCES c_forum_forum (iid)'); |
||
| 66 | } |
||
| 67 | |||
| 68 | if ($table->hasColumn('thread_poster_name')) { |
||
| 69 | $this->addSql('ALTER TABLE c_forum_thread DROP thread_poster_name'); |
||
| 70 | } |
||
| 71 | |||
| 72 | if (false === $table->hasForeignKey('FK_5DA7884C43CB876D')) { |
||
| 73 | $this->addSql('ALTER TABLE c_forum_thread ADD CONSTRAINT FK_5DA7884C43CB876D FOREIGN KEY (thread_last_post) REFERENCES c_forum_post (iid)'); |
||
| 74 | $this->addSql('CREATE INDEX IDX_5DA7884C43CB876D ON c_forum_thread (thread_last_post);'); |
||
| 75 | } |
||
| 76 | |||
| 77 | if (false === $table->hasForeignKey('FK_5DA7884CD4DC43B9')) { |
||
| 78 | $this->addSql('ALTER TABLE c_forum_thread ADD CONSTRAINT FK_5DA7884CD4DC43B9 FOREIGN KEY (thread_poster_id) REFERENCES user (id);'); |
||
| 79 | $this->addSql('CREATE INDEX IDX_5DA7884CD4DC43B9 ON c_forum_thread (thread_poster_id);'); |
||
| 80 | } |
||
| 83 |