| Conditions | 15 |
| Paths | 16384 |
| Total Lines | 80 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 14 | public function up(Schema $schema): void |
||
| 15 | { |
||
| 16 | $table = $schema->getTable('usergroup'); |
||
| 17 | if (!$table->hasForeignKey('FK_4A6478171BAD783F')) { |
||
| 18 | $this->addSql('ALTER TABLE usergroup ADD CONSTRAINT FK_4A6478171BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); |
||
| 19 | } |
||
| 20 | |||
| 21 | if (!$table->hasIndex('UNIQ_4A6478171BAD783F')) { |
||
| 22 | $this->addSql('CREATE UNIQUE INDEX UNIQ_4A6478171BAD783F ON usergroup (resource_node_id)'); |
||
| 23 | } |
||
| 24 | |||
| 25 | $table = $schema->getTable('usergroup'); |
||
| 26 | |||
| 27 | $this->addSql('ALTER TABLE usergroup_rel_course CHANGE usergroup_id usergroup_id INT DEFAULT NULL'); |
||
| 28 | $this->addSql('ALTER TABLE usergroup_rel_course CHANGE course_id course_id INT DEFAULT NULL'); |
||
| 29 | |||
| 30 | if (!$table->hasForeignKey('FK_4A8DF159D2112630')) { |
||
| 31 | $this->addSql( |
||
| 32 | 'ALTER TABLE usergroup_rel_course ADD CONSTRAINT FK_4A8DF159D2112630 FOREIGN KEY (usergroup_id) REFERENCES usergroup (id) ON DELETE CASCADE' |
||
| 33 | ); |
||
| 34 | } |
||
| 35 | |||
| 36 | if (!$table->hasForeignKey('FK_4A8DF159591CC992')) { |
||
| 37 | $this->addSql( |
||
| 38 | 'ALTER TABLE usergroup_rel_course ADD CONSTRAINT FK_4A8DF159591CC992 FOREIGN KEY (course_id) REFERENCES course (id) ON DELETE CASCADE' |
||
| 39 | ); |
||
| 40 | } |
||
| 41 | |||
| 42 | if (!$table->hasIndex('IDX_4A8DF159D2112630')) { |
||
| 43 | $this->addSql('CREATE INDEX IDX_4A8DF159D2112630 ON usergroup_rel_course (usergroup_id)'); |
||
| 44 | } |
||
| 45 | if (!$table->hasIndex('IDX_4A8DF159591CC992')) { |
||
| 46 | $this->addSql('CREATE INDEX IDX_4A8DF159591CC992 ON usergroup_rel_course (course_id)'); |
||
| 47 | } |
||
| 48 | |||
| 49 | $table = $schema->getTable('usergroup_rel_question'); |
||
| 50 | |||
| 51 | $this->addSql('ALTER TABLE usergroup_rel_question CHANGE question_id question_id INT DEFAULT NULL'); |
||
| 52 | $this->addSql('ALTER TABLE usergroup_rel_question CHANGE usergroup_id usergroup_id INT DEFAULT NULL'); |
||
| 53 | |||
| 54 | if (!$table->hasForeignKey('FK_FF3E58F21E27F6BF')) { |
||
| 55 | $this->addSql( |
||
| 56 | 'ALTER TABLE usergroup_rel_question ADD CONSTRAINT FK_FF3E58F21E27F6BF FOREIGN KEY (question_id) REFERENCES c_quiz_question (iid) ON DELETE CASCADE' |
||
| 57 | ); |
||
| 58 | } |
||
| 59 | if (!$table->hasForeignKey('FK_FF3E58F2D2112630')) { |
||
| 60 | $this->addSql( |
||
| 61 | 'ALTER TABLE usergroup_rel_question ADD CONSTRAINT FK_FF3E58F2D2112630 FOREIGN KEY (usergroup_id) REFERENCES usergroup (id) ON DELETE CASCADE' |
||
| 62 | ); |
||
| 63 | } |
||
| 64 | |||
| 65 | if (!$table->hasIndex('IDX_FF3E58F21E27F6BF')) { |
||
| 66 | $this->addSql('CREATE INDEX IDX_FF3E58F21E27F6BF ON usergroup_rel_question (question_id)'); |
||
| 67 | } |
||
| 68 | |||
| 69 | if (!$table->hasIndex('IDX_FF3E58F2D2112630')) { |
||
| 70 | $this->addSql('CREATE INDEX IDX_FF3E58F2D2112630 ON usergroup_rel_question (usergroup_id)'); |
||
| 71 | } |
||
| 72 | |||
| 73 | $table = $schema->getTable('usergroup_rel_session'); |
||
| 74 | |||
| 75 | $this->addSql('ALTER TABLE usergroup_rel_session CHANGE usergroup_id usergroup_id INT DEFAULT NULL'); |
||
| 76 | $this->addSql('ALTER TABLE usergroup_rel_session CHANGE session_id session_id INT DEFAULT NULL'); |
||
| 77 | |||
| 78 | if (!$table->hasForeignKey('FK_70122432D2112630')) { |
||
| 79 | $this->addSql( |
||
| 80 | 'ALTER TABLE usergroup_rel_session ADD CONSTRAINT FK_70122432D2112630 FOREIGN KEY (usergroup_id) REFERENCES usergroup (id) ON DELETE CASCADE' |
||
| 81 | ); |
||
| 82 | } |
||
| 83 | if (!$table->hasForeignKey('FK_70122432613FECDF')) { |
||
| 84 | $this->addSql( |
||
| 85 | 'ALTER TABLE usergroup_rel_session ADD CONSTRAINT FK_70122432613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE CASCADE' |
||
| 86 | ); |
||
| 87 | } |
||
| 88 | |||
| 89 | if (!$table->hasIndex('IDX_70122432D2112630')) { |
||
| 90 | $this->addSql('CREATE INDEX IDX_70122432D2112630 ON usergroup_rel_session (usergroup_id)'); |
||
| 91 | } |
||
| 92 | if (!$table->hasIndex('IDX_70122432613FECDF')) { |
||
| 93 | $this->addSql('CREATE INDEX IDX_70122432613FECDF ON usergroup_rel_session (session_id)'); |
||
| 94 | } |
||
| 106 |