| Conditions | 17 |
| Paths | > 20000 |
| Total Lines | 110 |
| Code Lines | 65 |
| 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 |
||
| 15 | public function up(Schema $schema): void |
||
| 16 | { |
||
| 17 | // access_url_rel_user. |
||
| 18 | $table = $schema->getTable('access_url_rel_user'); |
||
| 19 | if (false === $table->hasColumn('id')) { |
||
| 20 | $this->addSql('ALTER TABLE access_url_rel_user MODIFY COLUMN access_url_id INT NOT NULL'); |
||
| 21 | $this->addSql('ALTER TABLE access_url_rel_user MODIFY COLUMN user_id INT NOT NULL'); |
||
| 22 | $this->addSql('ALTER TABLE access_url_rel_user DROP PRIMARY KEY'); |
||
| 23 | $this->addSql( |
||
| 24 | 'ALTER TABLE access_url_rel_user ADD id INT AUTO_INCREMENT NOT NULL, CHANGE access_url_id access_url_id INT DEFAULT NULL, CHANGE user_id user_id INT DEFAULT NULL, ADD PRIMARY KEY (id);' |
||
| 25 | ); |
||
| 26 | if (false === $table->hasForeignKey('FK_85574263A76ED395')) { |
||
| 27 | $this->addSql('ALTER TABLE access_url_rel_user ADD CONSTRAINT FK_85574263A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | // access_url_rel_session. |
||
| 32 | $table = $schema->getTable('access_url_rel_session'); |
||
| 33 | if (false === $table->hasColumn('id')) { |
||
| 34 | $this->addSql('ALTER TABLE access_url_rel_session DROP PRIMARY KEY'); |
||
| 35 | $this->addSql( |
||
| 36 | 'ALTER TABLE access_url_rel_session ADD id INT AUTO_INCREMENT NOT NULL, CHANGE access_url_id access_url_id INT DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL, ADD PRIMARY KEY (id);' |
||
| 37 | ); |
||
| 38 | $this->addSql( |
||
| 39 | 'ALTER TABLE access_url_rel_session ADD CONSTRAINT FK_6CBA5F5D613FECDF FOREIGN KEY (session_id) REFERENCES session (id);' |
||
| 40 | ); |
||
| 41 | $this->addSql( |
||
| 42 | 'ALTER TABLE access_url_rel_session ADD CONSTRAINT FK_6CBA5F5D73444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id);' |
||
| 43 | ); |
||
| 44 | $this->addSql('CREATE INDEX IDX_6CBA5F5D613FECDF ON access_url_rel_session (session_id);'); |
||
| 45 | $this->addSql('CREATE INDEX IDX_6CBA5F5D73444FD5 ON access_url_rel_session (access_url_id);'); |
||
| 46 | } |
||
| 47 | |||
| 48 | // access_url. |
||
| 49 | $table = $schema->getTable('access_url'); |
||
| 50 | if (false === $table->hasColumn('limit_courses')) { |
||
| 51 | $this->addSql( |
||
| 52 | 'ALTER TABLE access_url ADD limit_courses INT DEFAULT NULL, ADD limit_active_courses INT DEFAULT NULL, ADD limit_sessions INT DEFAULT NULL, ADD limit_users INT DEFAULT NULL, ADD limit_teachers INT DEFAULT NULL, ADD limit_disk_space INT DEFAULT NULL, ADD email VARCHAR(255) DEFAULT NULL;' |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | $this->addSql( |
||
| 56 | 'ALTER TABLE access_url_rel_course_category CHANGE access_url_id access_url_id INT DEFAULT NULL, CHANGE course_category_id course_category_id INT DEFAULT NULL' |
||
| 57 | ); |
||
| 58 | |||
| 59 | if (false === $table->hasColumn('parent_id')) { |
||
| 60 | $this->addSql('ALTER TABLE access_url ADD parent_id INT DEFAULT NULL'); |
||
| 61 | $this->addSql( |
||
| 62 | 'ALTER TABLE access_url ADD CONSTRAINT FK_9436187B727ACA70 FOREIGN KEY (parent_id) REFERENCES access_url (id) ON DELETE CASCADE;' |
||
| 63 | ); |
||
| 64 | $this->addSql('CREATE INDEX IDX_9436187B727ACA70 ON access_url (parent_id);'); |
||
| 65 | } |
||
| 66 | |||
| 67 | if (false === $table->hasColumn('tree_root')) { |
||
| 68 | $this->addSql('ALTER TABLE access_url ADD tree_root INT DEFAULT NULL'); |
||
| 69 | $this->addSql( |
||
| 70 | 'ALTER TABLE access_url ADD CONSTRAINT FK_9436187BA977936C FOREIGN KEY (tree_root) REFERENCES access_url (id) ON DELETE CASCADE;' |
||
| 71 | ); |
||
| 72 | $this->addSql('CREATE INDEX IDX_9436187BA977936C ON access_url (tree_root);'); |
||
| 73 | } |
||
| 74 | |||
| 75 | if (false === $table->hasColumn('resource_node_id')) { |
||
| 76 | $this->addSql('ALTER TABLE access_url ADD resource_node_id INT DEFAULT NULL'); |
||
| 77 | $this->addSql( |
||
| 78 | 'ALTER TABLE access_url ADD CONSTRAINT FK_9436187B1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;' |
||
| 79 | ); |
||
| 80 | $this->addSql('CREATE UNIQUE INDEX UNIQ_9436187B1BAD783F ON access_url (resource_node_id);'); |
||
| 81 | } |
||
| 82 | |||
| 83 | if (false === $table->hasColumn('lft')) { |
||
| 84 | $this->addSql('ALTER TABLE access_url ADD lft INT NOT NULL'); |
||
| 85 | } |
||
| 86 | |||
| 87 | if (false === $table->hasColumn('lvl')) { |
||
| 88 | $this->addSql('ALTER TABLE access_url ADD lvl INT NOT NULL'); |
||
| 89 | } |
||
| 90 | |||
| 91 | if (false === $table->hasColumn('rgt')) { |
||
| 92 | $this->addSql('ALTER TABLE access_url ADD rgt INT NOT NULL;'); |
||
| 93 | } |
||
| 94 | |||
| 95 | // access_url_rel_course_category. |
||
| 96 | $table = $schema->getTable('access_url_rel_course_category'); |
||
| 97 | if (false === $table->hasForeignKey('FK_3545C2A673444FD5')) { |
||
| 98 | $this->addSql( |
||
| 99 | 'ALTER TABLE access_url_rel_course_category ADD CONSTRAINT FK_3545C2A673444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id)' |
||
| 100 | ); |
||
| 101 | } |
||
| 102 | if (false === $table->hasForeignKey('FK_3545C2A66628AD36')) { |
||
| 103 | $this->addSql( |
||
| 104 | 'ALTER TABLE access_url_rel_course_category ADD CONSTRAINT FK_3545C2A66628AD36 FOREIGN KEY (course_category_id) REFERENCES course_category (id)' |
||
| 105 | ); |
||
| 106 | } |
||
| 107 | if (false === $table->hasIndex('IDX_3545C2A673444FD5')) { |
||
| 108 | $this->addSql('CREATE INDEX IDX_3545C2A673444FD5 ON access_url_rel_course_category (access_url_id)'); |
||
| 109 | } |
||
| 110 | if (false === $table->hasIndex('IDX_3545C2A66628AD36')) { |
||
| 111 | $this->addSql('CREATE INDEX IDX_3545C2A66628AD36 ON access_url_rel_course_category (course_category_id)'); |
||
| 112 | } |
||
| 113 | |||
| 114 | $this->addSql('ALTER TABLE access_url_rel_usergroup CHANGE access_url_id access_url_id INT DEFAULT NULL'); |
||
| 115 | |||
| 116 | // access_url_rel_usergroup. |
||
| 117 | $table = $schema->getTable('access_url_rel_usergroup'); |
||
| 118 | if (false === $table->hasForeignKey('FK_AD488DD573444FD5')) { |
||
| 119 | $this->addSql( |
||
| 120 | 'ALTER TABLE access_url_rel_usergroup ADD CONSTRAINT FK_AD488DD573444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id)' |
||
| 121 | ); |
||
| 122 | } |
||
| 123 | if (false === $table->hasIndex('IDX_AD488DD573444FD5')) { |
||
| 124 | $this->addSql('CREATE INDEX IDX_AD488DD573444FD5 ON access_url_rel_usergroup (access_url_id)'); |
||
| 125 | } |
||
| 132 |