Conditions | 17 |
Paths | > 20000 |
Total Lines | 106 |
Code Lines | 56 |
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 |
||
17 | public function up(Schema $schema): void |
||
18 | { |
||
19 | if ($schema->hasTable('ticket_ticket')) { |
||
20 | $table = $schema->getTable('ticket_ticket'); |
||
21 | if (!$table->hasColumn('exercise_id')) { |
||
22 | $this->addSql( |
||
23 | 'ALTER TABLE ticket_ticket ADD exercise_id INT DEFAULT NULL' |
||
24 | ); |
||
25 | } |
||
26 | if (!$table->hasColumn('lp_id')) { |
||
27 | $this->addSql( |
||
28 | 'ALTER TABLE ticket_ticket ADD lp_id INT DEFAULT NULL' |
||
29 | ); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | if ($schema->hasTable('c_quiz_question_rel_category')) { |
||
34 | $table = $schema->getTable('c_quiz_question_rel_category'); |
||
35 | if (!$table->hasColumn('mandatory')) { |
||
36 | $this->addSql( |
||
37 | 'ALTER TABLE c_quiz_question_rel_category ADD COLUMN mandatory INT DEFAULT 0' |
||
38 | ); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | if (!$schema->hasTable('c_plagiarism_compilatio_docs')) { |
||
43 | $this->addSql( |
||
44 | 'CREATE TABLE c_plagiarism_compilatio_docs (id INT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, document_id INT NOT NULL, compilatio_id VARCHAR(32) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | if (!$schema->hasTable('notification_event')) { |
||
49 | $this->addSql( |
||
50 | 'CREATE TABLE notification_event (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, content LONGTEXT DEFAULT NULL, link LONGTEXT DEFAULT NULL, persistent INT DEFAULT NULL, day_diff INT DEFAULT NULL, event_type VARCHAR(255) NOT NULL, event_id INT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
||
51 | ); |
||
52 | } |
||
53 | |||
54 | if ($schema->hasTable('system_template')) { |
||
55 | $table = $schema->getTable('system_template'); |
||
56 | if (!$table->hasColumn('language')) { |
||
57 | $this->addSql( |
||
58 | 'ALTER TABLE system_template ADD language VARCHAR(40) NOT NULL DEFAULT "english"' |
||
59 | ); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | if (!$schema->hasTable('agenda_reminder')) { |
||
64 | $this->addSql( |
||
65 | 'CREATE TABLE agenda_reminder (id BIGINT AUTO_INCREMENT NOT NULL, type VARCHAR(255) NOT NULL, event_id INT NOT NULL, date_interval VARCHAR(255) NOT NULL COMMENT "(DC2Type:dateinterval)", sent TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;' |
||
66 | ); |
||
67 | } |
||
68 | |||
69 | if (!$schema->hasTable('notification_event_rel_user')) { |
||
70 | $this->addSql('CREATE TABLE notification_event_rel_user ( |
||
71 | id INT UNSIGNED AUTO_INCREMENT NOT NULL, |
||
72 | event_id INT UNSIGNED, |
||
73 | user_id INT, |
||
74 | PRIMARY KEY (id) |
||
75 | )'); |
||
76 | } |
||
77 | |||
78 | if (!$schema->hasTable('message_feedback')) { |
||
79 | $this->addSql( |
||
80 | 'CREATE TABLE message_feedback (id BIGINT AUTO_INCREMENT NOT NULL, message_id BIGINT NOT NULL, user_id INT NOT NULL, liked TINYINT(1) DEFAULT 0 NOT NULL, disliked TINYINT(1) DEFAULT 0 NOT NULL, updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", INDEX IDX_DB0F8049537A1329 (message_id), INDEX IDX_DB0F8049A76ED395 (user_id), INDEX idx_message_feedback_uid_mid (message_id, user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
||
81 | ); |
||
82 | $this->addSql( |
||
83 | 'ALTER TABLE message_feedback ADD CONSTRAINT FK_DB0F8049537A1329 FOREIGN KEY (message_id) REFERENCES message (id) ON DELETE CASCADE' |
||
84 | ); |
||
85 | $this->addSql( |
||
86 | 'ALTER TABLE message_feedback ADD CONSTRAINT FK_DB0F8049A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE' |
||
87 | ); |
||
88 | } |
||
89 | |||
90 | if (!$schema->hasTable('portfolio_attachment')) { |
||
91 | $this->addSql( |
||
92 | 'CREATE TABLE portfolio_attachment (id INT AUTO_INCREMENT NOT NULL, path VARCHAR(255) NOT NULL, comment LONGTEXT DEFAULT NULL, size INT NOT NULL, filename VARCHAR(255) NOT NULL, origin_id INT NOT NULL, origin_type INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
||
93 | ); |
||
94 | } |
||
95 | |||
96 | if (!$schema->hasTable('portfolio_comment')) { |
||
97 | $this->addSql( |
||
98 | 'CREATE TABLE portfolio_comment (id INT AUTO_INCREMENT NOT NULL, author_id INT NOT NULL, item_id INT NOT NULL, tree_root INT DEFAULT NULL, parent_id INT DEFAULT NULL, visibility SMALLINT DEFAULT 1 NOT NULL, content LONGTEXT NOT NULL, date DATETIME NOT NULL COMMENT "(DC2Type:datetime)", is_important TINYINT(1) DEFAULT 0 NOT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, score DOUBLE PRECISION DEFAULT NULL, is_template TINYINT(1) DEFAULT 0 NOT NULL, INDEX IDX_C2C17DA2F675F31B (author_id), INDEX IDX_C2C17DA2126F525E (item_id), INDEX IDX_C2C17DA2A977936C (tree_root), INDEX IDX_C2C17DA2727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
||
99 | ); |
||
100 | $this->addSql( |
||
101 | 'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2F675F31B FOREIGN KEY (author_id) REFERENCES user (id) ON DELETE CASCADE' |
||
102 | ); |
||
103 | $this->addSql( |
||
104 | 'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2126F525E FOREIGN KEY (item_id) REFERENCES portfolio (id) ON DELETE CASCADE' |
||
105 | ); |
||
106 | $this->addSql( |
||
107 | 'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2A977936C FOREIGN KEY (tree_root) REFERENCES portfolio_comment (id) ON DELETE CASCADE' |
||
108 | ); |
||
109 | $this->addSql( |
||
110 | 'ALTER TABLE portfolio_comment ADD CONSTRAINT FK_C2C17DA2727ACA70 FOREIGN KEY (parent_id) REFERENCES portfolio_comment (id) ON DELETE CASCADE' |
||
111 | ); |
||
112 | } |
||
113 | |||
114 | if ($schema->hasTable('portfolio')) { |
||
115 | $this->addSql( |
||
116 | 'ALTER TABLE portfolio ADD origin INT DEFAULT NULL, ADD origin_type INT DEFAULT NULL, ADD score DOUBLE PRECISION DEFAULT NULL, ADD is_highlighted TINYINT(1) DEFAULT 0 NOT NULL, ADD is_template TINYINT(1) DEFAULT 0 NOT NULL' |
||
117 | ); |
||
118 | } |
||
119 | |||
120 | if (!$schema->hasTable('c_attendance_result_comment')) { |
||
121 | $this->addSql( |
||
122 | 'CREATE TABLE c_attendance_result_comment (iid INT AUTO_INCREMENT NOT NULL, attendance_sheet_id INT NOT NULL, user_id INT NOT NULL, comment LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", updated_at DATETIME NOT NULL COMMENT "(DC2Type:datetime)", author_user_id INT NOT NULL, INDEX attendance_sheet_id (attendance_sheet_id), INDEX user_id (user_id), PRIMARY KEY(iid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC' |
||
123 | ); |
||
212 |