Conditions | 22 |
Paths | > 20000 |
Total Lines | 123 |
Code Lines | 71 |
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 |
||
19 | public function up(Schema $schema): void |
||
20 | { |
||
21 | error_log('MIGRATIONS :: FILE -- Version20201211114900 ...'); |
||
22 | |||
23 | if ($schema->hasTable('gradebook_category')) { |
||
24 | $table = $schema->getTable('gradebook_category'); |
||
25 | if (!$table->hasColumn('allow_skills_by_subcategory')) { |
||
26 | $this->addSql( |
||
27 | 'ALTER TABLE gradebook_category ADD allow_skills_by_subcategory INT DEFAULT 1' |
||
28 | ); |
||
29 | } |
||
30 | } |
||
31 | |||
32 | if ($schema->hasTable('c_survey_answer')) { |
||
33 | $table = $schema->getTable('c_survey_answer'); |
||
34 | if (!$table->hasColumn('session_id')) { |
||
35 | $this->addSql( |
||
36 | 'ALTER TABLE c_survey_answer ADD session_id INT NOT NULL' |
||
37 | ); |
||
38 | } |
||
39 | if (!$table->hasColumn('c_lp_item_id')) { |
||
40 | $this->addSql( |
||
41 | 'ALTER TABLE c_survey_answer ADD c_lp_item_id INT NOT NULL' |
||
42 | ); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | if ($schema->hasTable('c_survey_invitation')) { |
||
47 | $table = $schema->getTable('c_survey_invitation'); |
||
48 | if (!$table->hasColumn('c_lp_item_id')) { |
||
49 | $this->addSql( |
||
50 | 'ALTER TABLE c_survey_invitation ADD c_lp_item_id INT NOT NULL' |
||
51 | ); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | if ($schema->hasTable('c_quiz')) { |
||
56 | $table = $schema->getTable('c_quiz'); |
||
57 | if (!$table->hasColumn('hide_attempts_table')) { |
||
58 | $this->addSql( |
||
59 | 'ALTER TABLE c_quiz ADD hide_attempts_table TINYINT(1) NOT NULL' |
||
60 | ); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | if ($schema->hasTable('c_attendance_calendar')) { |
||
65 | $table = $schema->getTable('c_attendance_calendar'); |
||
66 | if (!$table->hasColumn('blocked')) { |
||
67 | $this->addSql( |
||
68 | 'ALTER TABLE c_attendance_calendar ADD blocked TINYINT(1) DEFAULT NULL' |
||
69 | ); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | if ($schema->hasTable('c_attendance_sheet')) { |
||
74 | $table = $schema->getTable('c_attendance_sheet'); |
||
75 | if (!$table->hasColumn('signature')) { |
||
76 | $this->addSql( |
||
77 | 'ALTER TABLE c_attendance_sheet ADD signature VARCHAR(255) DEFAULT NULL' |
||
78 | ); |
||
79 | } |
||
80 | } |
||
81 | |||
82 | if ($schema->hasTable('c_lp')) { |
||
83 | $table = $schema->getTable('c_lp'); |
||
84 | if (!$table->hasColumn('published_on')) { |
||
85 | $this->addSql( |
||
86 | 'ALTER TABLE c_lp CHANGE publicated_on published_on datetime NULL;' |
||
87 | ); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | if ($schema->hasTable('c_lp')) { |
||
92 | $table = $schema->getTable('c_lp'); |
||
93 | if (!$table->hasColumn('next_lp_id')) { |
||
94 | $this->addSql( |
||
95 | 'ALTER TABLE c_lp ADD next_lp_id INT DEFAULT 0 NOT NULL' |
||
96 | ); |
||
97 | } |
||
98 | } |
||
99 | |||
100 | if ($schema->hasTable('c_lp_item')) { |
||
101 | $table = $schema->getTable('c_lp_item'); |
||
102 | if (!$table->hasColumn('item_root')) { |
||
103 | $this->addSql( |
||
104 | 'ALTER TABLE c_lp_item CHANGE c_id item_root INT DEFAULT NULL' |
||
105 | ); |
||
106 | $this->addSql( |
||
107 | 'ALTER TABLE c_lp_item ADD CONSTRAINT FK_CCC9C1EDDEC4BDA0 FOREIGN KEY (item_root) REFERENCES c_lp_item (iid) ON DELETE CASCADE' |
||
108 | ); |
||
109 | $this->addSql( |
||
110 | 'CREATE INDEX IDX_CCC9C1EDDEC4BDA0 ON c_lp_item (item_root)' |
||
111 | ); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | if (!$schema->hasTable('c_wiki_category')) { |
||
116 | $this->addSql( |
||
117 | 'CREATE TABLE c_wiki_category (id INT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, session_id INT DEFAULT NULL, tree_root INT DEFAULT NULL, parent_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, INDEX IDX_17F1099A91D79BD3 (c_id), INDEX IDX_17F1099A613FECDF (session_id), INDEX IDX_17F1099AA977936C (tree_root), INDEX IDX_17F1099A727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
||
118 | ); |
||
119 | $this->addSql( |
||
120 | 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE' |
||
121 | ); |
||
122 | $this->addSql( |
||
123 | 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE CASCADE' |
||
124 | ); |
||
125 | $this->addSql( |
||
126 | 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099AA977936C FOREIGN KEY (tree_root) REFERENCES c_wiki_category (id) ON DELETE CASCADE' |
||
127 | ); |
||
128 | $this->addSql( |
||
129 | 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A727ACA70 FOREIGN KEY (parent_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE' |
||
130 | ); |
||
131 | } |
||
132 | |||
133 | if (!$schema->hasTable('c_wiki_rel_category')) { |
||
134 | $this->addSql( |
||
135 | 'CREATE TABLE c_wiki_rel_category (wiki_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_AC88945BAA948DBE (wiki_id), INDEX IDX_AC88945B12469DE2 (category_id), PRIMARY KEY(wiki_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
||
136 | ); |
||
137 | $this->addSql( |
||
138 | 'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945BAA948DBE FOREIGN KEY (wiki_id) REFERENCES c_wiki (iid) ON DELETE CASCADE' |
||
139 | ); |
||
140 | $this->addSql( |
||
141 | 'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945B12469DE2 FOREIGN KEY (category_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE' |
||
142 | ); |
||
217 |