| Conditions | 30 |
| Paths | > 20000 |
| Total Lines | 144 |
| Code Lines | 76 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 15 | public function up(Schema $schema): void |
||
| 16 | { |
||
| 17 | $em = $this->getEntityManager(); |
||
| 18 | $container = $this->getContainer(); |
||
| 19 | |||
| 20 | // CAttendance |
||
| 21 | $table = $schema->getTable('c_attendance'); |
||
| 22 | if ($table->hasIndex('course')) { |
||
| 23 | $this->addSql('DROP INDEX course ON c_attendance'); |
||
| 24 | } |
||
| 25 | if ($table->hasIndex('session_id')) { |
||
| 26 | $this->addSql('DROP INDEX session_id ON c_attendance'); |
||
| 27 | } |
||
| 28 | |||
| 29 | $this->addSql('ALTER TABLE c_attendance CHANGE active active INT NOT NULL'); |
||
| 30 | |||
| 31 | if (false === $table->hasColumn('resource_node_id')) { |
||
| 32 | $this->addSql('ALTER TABLE c_attendance ADD resource_node_id INT DEFAULT NULL'); |
||
| 33 | $this->addSql('ALTER TABLE c_attendance ADD CONSTRAINT FK_413634921BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); |
||
| 34 | $this->addSql('CREATE UNIQUE INDEX UNIQ_413634921BAD783F ON c_attendance (resource_node_id)'); |
||
| 35 | } |
||
| 36 | |||
| 37 | $table = $schema->getTable('c_attendance_calendar'); |
||
| 38 | if ($table->hasIndex('course')) { |
||
| 39 | $this->addSql('DROP INDEX course ON c_attendance_calendar'); |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($table->hasIndex('attendance_id')) { |
||
| 43 | $this->addSql('DROP INDEX attendance_id ON c_attendance_calendar'); |
||
| 44 | } |
||
| 45 | |||
| 46 | $this->addSql('ALTER TABLE c_attendance_calendar CHANGE attendance_id attendance_id INT DEFAULT NULL;'); |
||
| 47 | |||
| 48 | if (false === $table->hasForeignKey('FK_AA3A9AB8163DDA15')) { |
||
| 49 | $this->addSql('ALTER TABLE c_attendance_calendar ADD CONSTRAINT FK_AA3A9AB8163DDA15 FOREIGN KEY (attendance_id) REFERENCES c_attendance (iid);'); |
||
| 50 | } |
||
| 51 | |||
| 52 | if ($table->hasIndex('attendance_id')) { |
||
| 53 | $this->addSql('DROP INDEX attendance_id ON c_attendance_calendar'); |
||
| 54 | } |
||
| 55 | |||
| 56 | if (false === $table->hasIndex('attendance_id')) { |
||
| 57 | $this->addSql('CREATE INDEX IDX_AA3A9AB8163DDA15 ON c_attendance_calendar (attendance_id);'); |
||
| 58 | } |
||
| 59 | |||
| 60 | $table = $schema->getTable('c_attendance_sheet'); |
||
| 61 | |||
| 62 | if ($table->hasIndex('course')) { |
||
| 63 | $this->addSql('DROP INDEX course ON c_attendance_sheet;'); |
||
| 64 | } |
||
| 65 | |||
| 66 | if ($table->hasIndex('user')) { |
||
| 67 | $this->addSql('DROP INDEX user ON c_attendance_sheet;'); |
||
| 68 | } |
||
| 69 | |||
| 70 | $this->addSql('UPDATE c_attendance_sheet SET attendance_calendar_id = NULL WHERE attendance_calendar_id = 0;'); |
||
| 71 | $this->addSql('ALTER TABLE c_attendance_sheet CHANGE user_id user_id INT DEFAULT NULL, CHANGE attendance_calendar_id attendance_calendar_id INT DEFAULT NULL'); |
||
| 72 | |||
| 73 | //ALTER TABLE c_attendance_sheet DROP c_id |
||
| 74 | |||
| 75 | if (false === $table->hasForeignKey('FK_AD1394FAA76ED395')) { |
||
| 76 | $this->addSql('ALTER TABLE c_attendance_sheet ADD CONSTRAINT FK_AD1394FAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id);'); |
||
| 77 | } |
||
| 78 | |||
| 79 | if (false === $table->hasForeignKey('FK_AD1394FA19EA43C3')) { |
||
| 80 | $this->addSql('ALTER TABLE c_attendance_sheet ADD CONSTRAINT FK_AD1394FA19EA43C3 FOREIGN KEY (attendance_calendar_id) REFERENCES c_attendance_calendar (iid);'); |
||
| 81 | } |
||
| 82 | |||
| 83 | if (false === $table->hasIndex('IDX_AD1394FA19EA43C3')) { |
||
| 84 | $this->addSql('CREATE INDEX IDX_AD1394FA19EA43C3 ON c_attendance_sheet (attendance_calendar_id);'); |
||
| 85 | } |
||
| 86 | if ($table->hasIndex('user')) { |
||
| 87 | $this->addSql('DROP INDEX user ON c_attendance_sheet;'); |
||
| 88 | } |
||
| 89 | |||
| 90 | if (false === $table->hasIndex('IDX_AD1394FAA76ED395')) { |
||
| 91 | $this->addSql('CREATE INDEX IDX_AD1394FAA76ED395 ON c_attendance_sheet (user_id);'); |
||
| 92 | } |
||
| 93 | |||
| 94 | $table = $schema->getTable('c_attendance_result'); |
||
| 95 | |||
| 96 | if ($table->hasIndex('course')) { |
||
| 97 | $this->addSql('DROP INDEX course ON c_attendance_result'); |
||
| 98 | } |
||
| 99 | |||
| 100 | $this->addSql('UPDATE c_attendance_result SET attendance_id = NULL WHERE attendance_id = 0;'); |
||
| 101 | //ALTER TABLE c_attendance_result DROP c_id, ; |
||
| 102 | $this->addSql('ALTER TABLE c_attendance_result CHANGE user_id user_id INT DEFAULT NULL, CHANGE attendance_id attendance_id INT DEFAULT NULL '); |
||
| 103 | |||
| 104 | //ALTER TABLE c_attendance_sheet DROP c_id |
||
| 105 | |||
| 106 | if (false === $table->hasForeignKey('FK_2C7640A76ED395')) { |
||
| 107 | $this->addSql('ALTER TABLE c_attendance_result ADD CONSTRAINT FK_2C7640A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);'); |
||
| 108 | } |
||
| 109 | if (false === $table->hasForeignKey('FK_2C7640163DDA15')) { |
||
| 110 | $this->addSql('ALTER TABLE c_attendance_result ADD CONSTRAINT FK_2C7640163DDA15 FOREIGN KEY (attendance_id) REFERENCES c_attendance (iid);'); |
||
| 111 | } |
||
| 112 | if ($table->hasIndex('user_id')) { |
||
| 113 | $this->addSql('DROP INDEX user_id ON c_attendance_result;'); |
||
| 114 | } |
||
| 115 | if (false === $table->hasIndex('IDX_2C7640A76ED395')) { |
||
| 116 | $this->addSql('CREATE INDEX IDX_2C7640A76ED395 ON c_attendance_result (user_id);'); |
||
| 117 | } |
||
| 118 | |||
| 119 | if ($table->hasIndex('attendance_id')) { |
||
| 120 | $this->addSql('DROP INDEX attendance_id ON c_attendance_result;'); |
||
| 121 | } |
||
| 122 | |||
| 123 | if (false === $table->hasIndex('IDX_2C7640163DDA15')) { |
||
| 124 | $this->addSql('CREATE INDEX IDX_2C7640163DDA15 ON c_attendance_result (attendance_id);'); |
||
| 125 | } |
||
| 126 | |||
| 127 | $table = $schema->getTable('c_attendance_calendar_rel_group'); |
||
| 128 | |||
| 129 | if ($table->hasIndex('course')) { |
||
| 130 | $this->addSql('DROP INDEX course ON c_attendance_calendar_rel_group'); |
||
| 131 | } |
||
| 132 | |||
| 133 | //ALTER TABLE c_attendance_calendar_rel_group DROP c_id, |
||
| 134 | $this->addSql('UPDATE c_attendance_calendar_rel_group SET group_id = NULL WHERE group_id = 0'); |
||
| 135 | $this->addSql('UPDATE c_attendance_calendar_rel_group SET calendar_id = NULL WHERE calendar_id = 0'); |
||
| 136 | $this->addSql('ALTER TABLE c_attendance_calendar_rel_group CHANGE group_id group_id INT DEFAULT NULL, CHANGE calendar_id calendar_id INT DEFAULT NULL;'); |
||
| 137 | |||
| 138 | if ($table->hasIndex('course')) { |
||
| 139 | $this->addSql('DROP INDEX course ON c_attendance_calendar_rel_group'); |
||
| 140 | } |
||
| 141 | |||
| 142 | if (false === $table->hasForeignKey('FK_C2AB1FACFE54D947')) { |
||
| 143 | $this->addSql('ALTER TABLE c_attendance_calendar_rel_group ADD CONSTRAINT FK_C2AB1FACFE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid);'); |
||
| 144 | } |
||
| 145 | |||
| 146 | if (false === $table->hasForeignKey('FK_C2AB1FACA40A2C8')) { |
||
| 147 | $this->addSql('ALTER TABLE c_attendance_calendar_rel_group ADD CONSTRAINT FK_C2AB1FACA40A2C8 FOREIGN KEY (calendar_id) REFERENCES c_attendance_calendar (iid);'); |
||
| 148 | } |
||
| 149 | |||
| 150 | if (false === $table->hasIndex('IDX_C2AB1FACA40A2C8')) { |
||
| 151 | $this->addSql('CREATE INDEX IDX_C2AB1FACA40A2C8 ON c_attendance_calendar_rel_group (calendar_id);'); |
||
| 152 | } |
||
| 153 | |||
| 154 | if ($table->hasIndex('group')) { |
||
| 155 | $this->addSql('DROP INDEX `group` ON c_attendance_calendar_rel_group;'); |
||
| 156 | } |
||
| 157 | if (false === $table->hasIndex('IDX_C2AB1FACFE54D947')) { |
||
| 158 | $this->addSql('CREATE INDEX IDX_C2AB1FACFE54D947 ON c_attendance_calendar_rel_group (group_id);'); |
||
| 159 | } |
||
| 166 |