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 ProjectLocaleMigration_100 |
10
|
|
|
*/ |
11
|
|
|
class ProjectLocaleMigration_100 extends Migration |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Define the table structure |
15
|
|
|
* |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
|
|
public function morph() |
19
|
|
|
{ |
20
|
|
|
$this->morphTable('project_locale', [ |
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
|
|
|
'project_id', |
35
|
|
|
[ |
36
|
|
|
'type' => Column::TYPE_INTEGER, |
37
|
|
|
'unsigned' => true, |
38
|
|
|
'notNull' => true, |
39
|
|
|
'size' => 10, |
40
|
|
|
'after' => 'id' |
41
|
|
|
] |
42
|
|
|
), |
43
|
|
|
new Column( |
44
|
|
|
'locale_id', |
45
|
|
|
[ |
46
|
|
|
'type' => Column::TYPE_INTEGER, |
47
|
|
|
'unsigned' => true, |
48
|
|
|
'notNull' => true, |
49
|
|
|
'size' => 10, |
50
|
|
|
'after' => 'project_id' |
51
|
|
|
] |
52
|
|
|
), |
53
|
|
|
new Column( |
54
|
|
|
'created_at', |
55
|
|
|
[ |
56
|
|
|
'type' => Column::TYPE_DATETIME, |
57
|
|
|
'default' => "current_timestamp()", |
58
|
|
|
'notNull' => true, |
59
|
|
|
'after' => 'locale_id' |
60
|
|
|
] |
61
|
|
|
), |
62
|
|
|
new Column( |
63
|
|
|
'updated_at', |
64
|
|
|
[ |
65
|
|
|
'type' => Column::TYPE_DATETIME, |
66
|
|
|
'notNull' => false, |
67
|
|
|
'after' => 'created_at' |
68
|
|
|
] |
69
|
|
|
), |
70
|
|
|
new Column( |
71
|
|
|
'deleted_at', |
72
|
|
|
[ |
73
|
|
|
'type' => Column::TYPE_DATETIME, |
74
|
|
|
'notNull' => false, |
75
|
|
|
'after' => 'updated_at' |
76
|
|
|
] |
77
|
|
|
), |
78
|
|
|
new Column( |
79
|
|
|
'deprecated_at', |
80
|
|
|
[ |
81
|
|
|
'type' => Column::TYPE_DATETIME, |
82
|
|
|
'notNull' => false, |
83
|
|
|
'after' => 'deleted_at' |
84
|
|
|
] |
85
|
|
|
), |
86
|
|
|
new Column( |
87
|
|
|
'deleted', |
88
|
|
|
[ |
89
|
|
|
'type' => Column::TYPE_TINYINTEGER, |
90
|
|
|
'default' => "0", |
91
|
|
|
'unsigned' => true, |
92
|
|
|
'notNull' => true, |
93
|
|
|
'size' => 1, |
94
|
|
|
'after' => 'deprecated_at' |
95
|
|
|
] |
96
|
|
|
), |
97
|
|
|
new Column( |
98
|
|
|
'deprecated', |
99
|
|
|
[ |
100
|
|
|
'type' => Column::TYPE_TINYINTEGER, |
101
|
|
|
'default' => "0", |
102
|
|
|
'unsigned' => true, |
103
|
|
|
'notNull' => true, |
104
|
|
|
'size' => 1, |
105
|
|
|
'after' => 'deleted' |
106
|
|
|
] |
107
|
|
|
) |
108
|
|
|
], |
109
|
|
|
'indexes' => [ |
110
|
|
|
new Index('PRIMARY', ['id'], 'PRIMARY'), |
111
|
|
|
new Index('id_UNIQUE', ['id'], 'UNIQUE'), |
112
|
|
|
new Index('project_locale_project_id_fk_idx', ['project_id'], ''), |
113
|
|
|
new Index('project_locale_locale_id_fk_idx', ['locale_id'], '') |
114
|
|
|
], |
115
|
|
|
'references' => [ |
116
|
|
|
new Reference( |
117
|
|
|
'project_locale_locale_id_fk', |
118
|
|
|
[ |
119
|
|
|
'referencedTable' => 'locale', |
120
|
|
|
'referencedSchema' => 'zemit', |
121
|
|
|
'columns' => ['locale_id'], |
122
|
|
|
'referencedColumns' => ['id'], |
123
|
|
|
'onUpdate' => 'CASCADE', |
124
|
|
|
'onDelete' => 'CASCADE' |
125
|
|
|
] |
126
|
|
|
), |
127
|
|
|
new Reference( |
128
|
|
|
'project_locale_project_id_fk', |
129
|
|
|
[ |
130
|
|
|
'referencedTable' => 'project', |
131
|
|
|
'referencedSchema' => 'zemit', |
132
|
|
|
'columns' => ['project_id'], |
133
|
|
|
'referencedColumns' => ['id'], |
134
|
|
|
'onUpdate' => 'CASCADE', |
135
|
|
|
'onDelete' => 'CASCADE' |
136
|
|
|
] |
137
|
|
|
) |
138
|
|
|
], |
139
|
|
|
'options' => [ |
140
|
|
|
'table_type' => 'BASE TABLE', |
141
|
|
|
'auto_increment' => '', |
142
|
|
|
'engine' => 'InnoDB', |
143
|
|
|
'table_collation' => 'utf8mb4_general_ci' |
144
|
|
|
], |
145
|
|
|
] |
146
|
|
|
); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Run the migrations |
151
|
|
|
* |
152
|
|
|
* @return void |
153
|
|
|
*/ |
154
|
|
|
public function up() |
155
|
|
|
{ |
156
|
|
|
|
157
|
|
|
} |
|
|
|
|
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Reverse the migrations |
161
|
|
|
* |
162
|
|
|
* @return void |
163
|
|
|
*/ |
164
|
|
|
public function down() |
165
|
|
|
{ |
166
|
|
|
|
167
|
|
|
} |
|
|
|
|
168
|
|
|
|
169
|
|
|
} |
170
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.