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 FlowMigration_100 |
10
|
|
|
*/ |
11
|
|
|
class FlowMigration_100 extends Migration |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Define the table structure |
15
|
|
|
* |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
|
|
public function morph() |
19
|
|
|
{ |
20
|
|
|
$this->morphTable('flow', [ |
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
|
|
|
'workflow_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
|
|
|
'created_at', |
45
|
|
|
[ |
46
|
|
|
'type' => Column::TYPE_DATETIME, |
47
|
|
|
'default' => "current_timestamp()", |
48
|
|
|
'notNull' => true, |
49
|
|
|
'after' => 'workflow_id' |
50
|
|
|
] |
51
|
|
|
), |
52
|
|
|
new Column( |
53
|
|
|
'updated_at', |
54
|
|
|
[ |
55
|
|
|
'type' => Column::TYPE_DATETIME, |
56
|
|
|
'notNull' => false, |
57
|
|
|
'after' => 'created_at' |
58
|
|
|
] |
59
|
|
|
), |
60
|
|
|
new Column( |
61
|
|
|
'deleted_at', |
62
|
|
|
[ |
63
|
|
|
'type' => Column::TYPE_DATETIME, |
64
|
|
|
'notNull' => false, |
65
|
|
|
'after' => 'updated_at' |
66
|
|
|
] |
67
|
|
|
), |
68
|
|
|
new Column( |
69
|
|
|
'deprecated_at', |
70
|
|
|
[ |
71
|
|
|
'type' => Column::TYPE_DATETIME, |
72
|
|
|
'notNull' => false, |
73
|
|
|
'after' => 'deleted_at' |
74
|
|
|
] |
75
|
|
|
), |
76
|
|
|
new Column( |
77
|
|
|
'deleted', |
78
|
|
|
[ |
79
|
|
|
'type' => Column::TYPE_TINYINTEGER, |
80
|
|
|
'default' => "0", |
81
|
|
|
'unsigned' => true, |
82
|
|
|
'notNull' => true, |
83
|
|
|
'size' => 1, |
84
|
|
|
'after' => 'deprecated_at' |
85
|
|
|
] |
86
|
|
|
), |
87
|
|
|
new Column( |
88
|
|
|
'deprecated', |
89
|
|
|
[ |
90
|
|
|
'type' => Column::TYPE_TINYINTEGER, |
91
|
|
|
'default' => "0", |
92
|
|
|
'unsigned' => true, |
93
|
|
|
'notNull' => true, |
94
|
|
|
'size' => 1, |
95
|
|
|
'after' => 'deleted' |
96
|
|
|
] |
97
|
|
|
) |
98
|
|
|
], |
99
|
|
|
'indexes' => [ |
100
|
|
|
new Index('PRIMARY', ['id'], 'PRIMARY'), |
101
|
|
|
new Index('id_UNIQUE', ['id'], 'UNIQUE'), |
102
|
|
|
new Index('flow_workflow_id_fk_idx', ['workflow_id'], '') |
103
|
|
|
], |
104
|
|
|
'references' => [ |
105
|
|
|
new Reference( |
106
|
|
|
'flow_workflow_id_fk', |
107
|
|
|
[ |
108
|
|
|
'referencedTable' => 'workspace', |
109
|
|
|
'referencedSchema' => 'zemit', |
110
|
|
|
'columns' => ['workflow_id'], |
111
|
|
|
'referencedColumns' => ['id'], |
112
|
|
|
'onUpdate' => 'CASCADE', |
113
|
|
|
'onDelete' => 'CASCADE' |
114
|
|
|
] |
115
|
|
|
) |
116
|
|
|
], |
117
|
|
|
'options' => [ |
118
|
|
|
'table_type' => 'BASE TABLE', |
119
|
|
|
'auto_increment' => '', |
120
|
|
|
'engine' => 'InnoDB', |
121
|
|
|
'table_collation' => 'utf8mb4_general_ci' |
122
|
|
|
], |
123
|
|
|
] |
124
|
|
|
); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Run the migrations |
129
|
|
|
* |
130
|
|
|
* @return void |
131
|
|
|
*/ |
132
|
|
|
public function up() |
133
|
|
|
{ |
134
|
|
|
|
135
|
|
|
} |
|
|
|
|
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Reverse the migrations |
139
|
|
|
* |
140
|
|
|
* @return void |
141
|
|
|
*/ |
142
|
|
|
public function down() |
143
|
|
|
{ |
144
|
|
|
|
145
|
|
|
} |
|
|
|
|
146
|
|
|
|
147
|
|
|
} |
148
|
|
|
|
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.