| Conditions | 18 |
| Paths | > 20000 |
| Total Lines | 104 |
| Code Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 17 | public function up(Schema $schema): void |
||
| 18 | { |
||
| 19 | $this->addSql('DELETE FROM track_e_exercises WHERE exe_user_id = 0 OR exe_user_id IS NULL'); |
||
| 20 | $this->addSql('ALTER TABLE track_e_exercises CHANGE exe_user_id exe_user_id INT NOT NULL'); |
||
| 21 | |||
| 22 | $this->addSql('UPDATE track_e_exercises SET session_id = 0 WHERE session_id IS NULL'); |
||
| 23 | $this->addSql('ALTER TABLE track_e_exercises CHANGE session_id session_id INT NOT NULL'); |
||
| 24 | |||
| 25 | $table = $schema->getTable('track_e_login'); |
||
| 26 | if (!$table->hasIndex('idx_track_e_login_date')) { |
||
| 27 | $this->addSql('CREATE INDEX idx_track_e_login_date ON track_e_login (login_date)'); |
||
| 28 | } |
||
| 29 | |||
| 30 | $table = $schema->getTable('track_e_default'); |
||
| 31 | if (!$table->hasIndex('idx_default_user_id')) { |
||
| 32 | $this->addSql('CREATE INDEX idx_default_user_id ON track_e_default (default_user_id)'); |
||
| 33 | } |
||
| 34 | |||
| 35 | $table = $schema->getTable('track_e_course_access'); |
||
| 36 | if (!$table->hasIndex('user_course_session_date')) { |
||
| 37 | $this->addSql( |
||
| 38 | 'CREATE INDEX user_course_session_date ON track_e_course_access (user_id, c_id, session_id, login_course_date)' |
||
| 39 | ); |
||
| 40 | } |
||
| 41 | $this->addSql('ALTER TABLE track_e_course_access CHANGE user_id user_id INT DEFAULT NULL'); |
||
| 42 | if (!$table->hasForeignKey('FK_E8C05DC5A76ED395')) { |
||
| 43 | $this->addSql( |
||
| 44 | 'ALTER TABLE track_e_course_access ADD CONSTRAINT FK_E8C05DC5A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE' |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | |||
| 48 | $table = $schema->getTable('track_e_access'); |
||
| 49 | if (!$table->hasIndex('user_course_session_date')) { |
||
| 50 | $this->addSql( |
||
| 51 | 'CREATE INDEX user_course_session_date ON track_e_access (access_user_id, c_id, access_session_id, access_date)' |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | |||
| 55 | $table = $schema->hasTable('track_e_access_complete'); |
||
| 56 | if (false === $table) { |
||
| 57 | $this->addSql( |
||
| 58 | 'CREATE TABLE track_e_access_complete (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, date_reg DATETIME NOT NULL, tool VARCHAR(255) NOT NULL, tool_id INT NOT NULL, tool_id_detail INT NOT NULL, action VARCHAR(255) NOT NULL, action_details VARCHAR(255) NOT NULL, current_id INT NOT NULL, ip_user VARCHAR(255) NOT NULL, user_agent VARCHAR(255) NOT NULL, session_id INT NOT NULL, c_id INT NOT NULL, ch_sid VARCHAR(255) NOT NULL, login_as INT NOT NULL, info LONGTEXT NOT NULL, url LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;' |
||
| 59 | ); |
||
| 60 | $this->addSql('ALTER TABLE track_e_access_complete ADD CONSTRAINT FK_57FAFDBFA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); |
||
| 61 | $this->addSql('CREATE INDEX IDX_57FAFDBFA76ED395 ON track_e_access_complete (user_id)'); |
||
| 62 | } |
||
| 63 | //$this->addSql('ALTER TABLE track_e_hotpotatoes CHANGE exe_result score SMALLINT NOT NULL'); |
||
| 64 | //$this->addSql('ALTER TABLE track_e_hotpotatoes CHANGE exe_weighting max_score SMALLINT NOT NULL'); |
||
| 65 | |||
| 66 | $table = $schema->getTable('track_e_exercises'); |
||
| 67 | if ($table->hasColumn('exe_weighting')) { |
||
| 68 | $this->addSql('ALTER TABLE track_e_exercises CHANGE exe_weighting max_score DOUBLE PRECISION NOT NULL'); |
||
| 69 | } |
||
| 70 | if ($table->hasColumn('exe_result')) { |
||
| 71 | $this->addSql('ALTER TABLE track_e_exercises CHANGE exe_result score DOUBLE PRECISION NOT NULL'); |
||
| 72 | } |
||
| 73 | |||
| 74 | if (false === $table->hasColumn('blocked_categories')) { |
||
| 75 | $this->addSql('ALTER TABLE track_e_exercises ADD blocked_categories LONGTEXT DEFAULT NULL'); |
||
| 76 | } |
||
| 77 | |||
| 78 | $table = $schema->getTable('track_e_hotspot'); |
||
| 79 | if (false === $table->hasForeignKey('FK_A89CC3B691D79BD3')) { |
||
| 80 | $this->addSql( |
||
| 81 | 'ALTER TABLE track_e_hotspot ADD CONSTRAINT FK_A89CC3B691D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)' |
||
| 82 | ); |
||
| 83 | } |
||
| 84 | if (false === $table->hasIndex('IDX_A89CC3B691D79BD3')) { |
||
| 85 | $this->addSql('CREATE INDEX IDX_A89CC3B691D79BD3 ON track_e_hotspot (c_id)'); |
||
| 86 | } |
||
| 87 | |||
| 88 | $table = $schema->getTable('track_e_attempt'); |
||
| 89 | $this->addSql('ALTER TABLE track_e_attempt CHANGE c_id c_id INT DEFAULT NULL'); |
||
| 90 | |||
| 91 | if (false === $table->hasForeignKey('FK_F8C342C391D79BD3')) { |
||
| 92 | $this->addSql( |
||
| 93 | 'ALTER TABLE track_e_attempt ADD CONSTRAINT FK_F8C342C391D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)' |
||
| 94 | ); |
||
| 95 | } |
||
| 96 | |||
| 97 | if (!$table->hasIndex('idx_track_e_attempt_tms')) { |
||
| 98 | $this->addSql('CREATE INDEX idx_track_e_attempt_tms ON track_e_attempt (tms)'); |
||
| 99 | } |
||
| 100 | |||
| 101 | if (false === $table->hasColumn('seconds_spent')) { |
||
| 102 | $this->addSql('ALTER TABLE track_e_attempt ADD seconds_spent INT NOT NULL, CHANGE user_id user_id INT DEFAULT NULL'); |
||
| 103 | } |
||
| 104 | |||
| 105 | if (false === $table->hasForeignKey('FK_A89CC3B691D79BD3')) { |
||
| 106 | $this->addSql('ALTER TABLE track_e_attempt ADD CONSTRAINT FK_F8C342C3A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE;'); |
||
| 107 | } |
||
| 108 | |||
| 109 | if (false === $schema->hasTable('track_e_exercise_confirmation')) { |
||
| 110 | $this->addSql( |
||
| 111 | "CREATE TABLE track_e_exercise_confirmation (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, course_id INT NOT NULL, attempt_id INT NOT NULL, quiz_id INT NOT NULL, session_id INT NOT NULL, confirmed TINYINT(1) DEFAULT '0' NOT NULL, questions_count INT NOT NULL, saved_answers_count INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_980C28C7A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;" |
||
| 112 | ); |
||
| 113 | $this->addSql( |
||
| 114 | 'ALTER TABLE track_e_exercise_confirmation ADD CONSTRAINT FK_980C28C7A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE;' |
||
| 115 | ); |
||
| 116 | } |
||
| 117 | |||
| 118 | $table = $schema->getTable('track_e_attempt_recording'); |
||
| 119 | if (false === $table->hasColumn('answer')) { |
||
| 120 | $this->addSql('ALTER TABLE track_e_attempt_recording ADD answer LONGTEXT DEFAULT NULL'); |
||
| 121 | } |
||
| 128 |