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

UserMigration_100   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 147
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 82
c 1
b 0
f 0
dl 0
loc 147
ccs 0
cts 30
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 2 1
A up() 0 2 1
B morph() 0 118 1
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 UserMigration_100
10
 */
11
class UserMigration_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 "UserMigration_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('user', [
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
                        'name',
35
                        [
36
                            'type' => Column::TYPE_VARCHAR,
37
                            'notNull' => true,
38
                            'size' => 60,
39
                            'after' => 'id'
40
                        ]
41
                    ),
42
                    new Column(
43
                        'email',
44
                        [
45
                            'type' => Column::TYPE_VARCHAR,
46
                            'notNull' => false,
47
                            'size' => 191,
48
                            'after' => 'name'
49
                        ]
50
                    ),
51
                    new Column(
52
                        'password',
53
                        [
54
                            'type' => Column::TYPE_VARCHAR,
55
                            'notNull' => false,
56
                            'size' => 120,
57
                            'after' => 'email'
58
                        ]
59
                    ),
60
                    new Column(
61
                        'token',
62
                        [
63
                            'type' => Column::TYPE_VARCHAR,
64
                            'notNull' => false,
65
                            'size' => 120,
66
                            'after' => 'password'
67
                        ]
68
                    ),
69
                    new Column(
70
                        'hash',
71
                        [
72
                            'type' => Column::TYPE_VARCHAR,
73
                            'notNull' => false,
74
                            'size' => 120,
75
                            'after' => 'token'
76
                        ]
77
                    ),
78
                    new Column(
79
                        'status',
80
                        [
81
                            'type' => Column::TYPE_CHAR,
82
                            'notNull' => false,
83
                            'size' => 20,
84
                            'after' => 'hash'
85
                        ]
86
                    ),
87
                    new Column(
88
                        'created_at',
89
                        [
90
                            'type' => Column::TYPE_DATETIME,
91
                            'default' => "current_timestamp()",
92
                            'notNull' => true,
93
                            'after' => 'status'
94
                        ]
95
                    ),
96
                    new Column(
97
                        'updated_at',
98
                        [
99
                            'type' => Column::TYPE_DATETIME,
100
                            'notNull' => false,
101
                            'after' => 'created_at'
102
                        ]
103
                    ),
104
                    new Column(
105
                        'deleted_at',
106
                        [
107
                            'type' => Column::TYPE_DATETIME,
108
                            'notNull' => false,
109
                            'after' => 'updated_at'
110
                        ]
111
                    ),
112
                    new Column(
113
                        'deleted',
114
                        [
115
                            'type' => Column::TYPE_TINYINTEGER,
116
                            'default' => "0",
117
                            'unsigned' => true,
118
                            'notNull' => true,
119
                            'size' => 1,
120
                            'after' => 'deleted_at'
121
                        ]
122
                    )
123
                ],
124
                'indexes' => [
125
                    new Index('PRIMARY', ['id'], 'PRIMARY'),
126
                    new Index('id_UNIQUE', ['id'], 'UNIQUE'),
127
                    new Index('name_UNIQUE', ['name'], 'UNIQUE'),
128
                    new Index('email_UNIQUE', ['email'], 'UNIQUE'),
129
                    new Index('token_UNIQUE', ['token'], 'UNIQUE')
130
                ],
131
                'options' => [
132
                    'table_type' => 'BASE TABLE',
133
                    'auto_increment' => '',
134
                    'engine' => 'InnoDB',
135
                    'table_collation' => 'utf8mb4_general_ci'
136
                ],
137
            ]
138
        );
139
    }
140
141
    /**
142
     * Run the migrations
143
     *
144
     * @return void
145
     */
146
    public function up()
147
    {
148
149
    }
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...
150
151
    /**
152
     * Reverse the migrations
153
     *
154
     * @return void
155
     */
156
    public function down()
157
    {
158
159
    }
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...
160
161
}
162