Test Failed
Push — master ( 741545...e25e21 )
by Julien
11:23
created

ErrorMigration_100::morph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 269
Code Lines 189

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 189
c 0
b 0
f 0
dl 0
loc 269
ccs 0
cts 76
cp 0
rs 8
cc 1
nc 1
nop 0
crap 2

How to fix   Long Method   

Long Method

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:

1
<?php 
2
3
use Phalcon\Db\Column;
4
use Phalcon\Db\Index;
5
use Phalcon\Db\Reference;
6
use Phalcon\Migrations\Mvc\Model\Migration;
7
8
/**
9
 * Class ErrorMigration_100
10
 */
11
class ErrorMigration_100 extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style introduced by
Class name "ErrorMigration_100" is not in PascalCase format

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
12
{
13
    /**
14
     * Define the table structure
15
     *
16
     * @return void
17
     */
18
    public function morph()
19
    {
20
        $this->morphTable('error', [
21
                'columns' => [
22
                    new Column(
23
                        'id',
24
                        [
25
                            'type' => Column::TYPE_INTEGER,
26
                            'unsigned' => true,
27
                            'notNull' => true,
28
                            'autoIncrement' => true,
29
                            'size' => 10,
30
                            'first' => true
31
                        ]
32
                    ),
33
                    new Column(
34
                        'user_id',
35
                        [
36
                            'type' => Column::TYPE_INTEGER,
37
                            'unsigned' => true,
38
                            'notNull' => false,
39
                            'size' => 10,
40
                            'after' => 'id'
41
                        ]
42
                    ),
43
                    new Column(
44
                        'role_id',
45
                        [
46
                            'type' => Column::TYPE_INTEGER,
47
                            'unsigned' => true,
48
                            'notNull' => false,
49
                            'size' => 10,
50
                            'after' => 'user_id'
51
                        ]
52
                    ),
53
                    new Column(
54
                        'channel_id',
55
                        [
56
                            'type' => Column::TYPE_INTEGER,
57
                            'unsigned' => true,
58
                            'notNull' => false,
59
                            'size' => 10,
60
                            'after' => 'role_id'
61
                        ]
62
                    ),
63
                    new Column(
64
                        'endpoint_id',
65
                        [
66
                            'type' => Column::TYPE_INTEGER,
67
                            'unsigned' => true,
68
                            'notNull' => false,
69
                            'size' => 10,
70
                            'after' => 'channel_id'
71
                        ]
72
                    ),
73
                    new Column(
74
                        'project_id',
75
                        [
76
                            'type' => Column::TYPE_INTEGER,
77
                            'unsigned' => true,
78
                            'notNull' => false,
79
                            'size' => 10,
80
                            'after' => 'endpoint_id'
81
                        ]
82
                    ),
83
                    new Column(
84
                        'workspace_id',
85
                        [
86
                            'type' => Column::TYPE_INTEGER,
87
                            'unsigned' => true,
88
                            'notNull' => false,
89
                            'size' => 10,
90
                            'after' => 'project_id'
91
                        ]
92
                    ),
93
                    new Column(
94
                        'version_id',
95
                        [
96
                            'type' => Column::TYPE_INTEGER,
97
                            'unsigned' => true,
98
                            'notNull' => false,
99
                            'size' => 10,
100
                            'after' => 'workspace_id'
101
                        ]
102
                    ),
103
                    new Column(
104
                        'type',
105
                        [
106
                            'type' => Column::TYPE_CHAR,
107
                            'notNull' => true,
108
                            'size' => 40,
109
                            'after' => 'version_id'
110
                        ]
111
                    ),
112
                    new Column(
113
                        'message',
114
                        [
115
                            'type' => Column::TYPE_TEXT,
116
                            'notNull' => true,
117
                            'after' => 'type'
118
                        ]
119
                    ),
120
                    new Column(
121
                        'stacktrace',
122
                        [
123
                            'type' => Column::TYPE_MEDIUMTEXT,
124
                            'notNull' => false,
125
                            'after' => 'message'
126
                        ]
127
                    ),
128
                    new Column(
129
                        'meta',
130
                        [
131
                            'type' => Column::TYPE_LONGTEXT,
132
                            'notNull' => false,
133
                            'after' => 'stacktrace'
134
                        ]
135
                    ),
136
                    new Column(
137
                        'created_at',
138
                        [
139
                            'type' => Column::TYPE_DATETIME,
140
                            'default' => "current_timestamp()",
141
                            'notNull' => true,
142
                            'after' => 'meta'
143
                        ]
144
                    ),
145
                    new Column(
146
                        'updated_at',
147
                        [
148
                            'type' => Column::TYPE_DATETIME,
149
                            'notNull' => false,
150
                            'after' => 'created_at'
151
                        ]
152
                    ),
153
                    new Column(
154
                        'deleted_at',
155
                        [
156
                            'type' => Column::TYPE_DATETIME,
157
                            'notNull' => false,
158
                            'after' => 'updated_at'
159
                        ]
160
                    ),
161
                    new Column(
162
                        'deprecated_at',
163
                        [
164
                            'type' => Column::TYPE_DATETIME,
165
                            'notNull' => false,
166
                            'after' => 'deleted_at'
167
                        ]
168
                    ),
169
                    new Column(
170
                        'deleted',
171
                        [
172
                            'type' => Column::TYPE_TINYINTEGER,
173
                            'default' => "0",
174
                            'unsigned' => true,
175
                            'notNull' => true,
176
                            'size' => 1,
177
                            'after' => 'deprecated_at'
178
                        ]
179
                    ),
180
                    new Column(
181
                        'deprecated',
182
                        [
183
                            'type' => Column::TYPE_TINYINTEGER,
184
                            'default' => "0",
185
                            'unsigned' => true,
186
                            'notNull' => true,
187
                            'size' => 1,
188
                            'after' => 'deleted'
189
                        ]
190
                    )
191
                ],
192
                'indexes' => [
193
                    new Index('PRIMARY', ['id'], 'PRIMARY'),
194
                    new Index('id_UNIQUE', ['id'], 'UNIQUE'),
195
                    new Index('error_user_id_fk_idx', ['user_id'], ''),
196
                    new Index('error_role_id_fk_idx', ['role_id'], ''),
197
                    new Index('error_channel_id_fk_idx', ['channel_id'], ''),
198
                    new Index('error_endpoint_id_fk_idx', ['endpoint_id'], ''),
199
                    new Index('error_project_id_fk_idx', ['project_id'], ''),
200
                    new Index('error_workspace_id_fk_idx', ['workspace_id'], ''),
201
                    new Index('error_version_id_fk_idx', ['version_id'], '')
202
                ],
203
                'references' => [
204
                    new Reference(
205
                        'error_channel_id_fk',
206
                        [
207
                            'referencedTable' => 'channel',
208
                            'referencedSchema' => 'zemit',
209
                            'columns' => ['channel_id'],
210
                            'referencedColumns' => ['id'],
211
                            'onUpdate' => 'CASCADE',
212
                            'onDelete' => 'SET NULL'
213
                        ]
214
                    ),
215
                    new Reference(
216
                        'error_endpoint_id_fk',
217
                        [
218
                            'referencedTable' => 'endpoint',
219
                            'referencedSchema' => 'zemit',
220
                            'columns' => ['endpoint_id'],
221
                            'referencedColumns' => ['id'],
222
                            'onUpdate' => 'CASCADE',
223
                            'onDelete' => 'SET NULL'
224
                        ]
225
                    ),
226
                    new Reference(
227
                        'error_project_id_fk',
228
                        [
229
                            'referencedTable' => 'project',
230
                            'referencedSchema' => 'zemit',
231
                            'columns' => ['project_id'],
232
                            'referencedColumns' => ['id'],
233
                            'onUpdate' => 'CASCADE',
234
                            'onDelete' => 'SET NULL'
235
                        ]
236
                    ),
237
                    new Reference(
238
                        'error_role_id_fk',
239
                        [
240
                            'referencedTable' => 'role',
241
                            'referencedSchema' => 'zemit',
242
                            'columns' => ['role_id'],
243
                            'referencedColumns' => ['id'],
244
                            'onUpdate' => 'CASCADE',
245
                            'onDelete' => 'SET NULL'
246
                        ]
247
                    ),
248
                    new Reference(
249
                        'error_user_id_fk',
250
                        [
251
                            'referencedTable' => 'user',
252
                            'referencedSchema' => 'zemit',
253
                            'columns' => ['user_id'],
254
                            'referencedColumns' => ['id'],
255
                            'onUpdate' => 'CASCADE',
256
                            'onDelete' => 'SET NULL'
257
                        ]
258
                    ),
259
                    new Reference(
260
                        'error_version_id_fk',
261
                        [
262
                            'referencedTable' => 'version',
263
                            'referencedSchema' => 'zemit',
264
                            'columns' => ['version_id'],
265
                            'referencedColumns' => ['id'],
266
                            'onUpdate' => 'CASCADE',
267
                            'onDelete' => 'SET NULL'
268
                        ]
269
                    ),
270
                    new Reference(
271
                        'error_workspace_id_fk',
272
                        [
273
                            'referencedTable' => 'workspace',
274
                            'referencedSchema' => 'zemit',
275
                            'columns' => ['workspace_id'],
276
                            'referencedColumns' => ['id'],
277
                            'onUpdate' => 'CASCADE',
278
                            'onDelete' => 'SET NULL'
279
                        ]
280
                    )
281
                ],
282
                'options' => [
283
                    'table_type' => 'BASE TABLE',
284
                    'auto_increment' => '',
285
                    'engine' => 'InnoDB',
286
                    'table_collation' => 'utf8mb4_general_ci'
287
                ],
288
            ]
289
        );
290
    }
291
292
    /**
293
     * Run the migrations
294
     *
295
     * @return void
296
     */
297
    public function up()
298
    {
299
300
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
301
302
    /**
303
     * Reverse the migrations
304
     *
305
     * @return void
306
     */
307
    public function down()
308
    {
309
310
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
311
312
}
313