55class Inital extends AbstractMigration
66{
77
8- /**
9- * Change Method.
10- *
11- * More information on this method is available here:
12- * http://docs.phinx.org/en/latest/migrations.html#the-change-method
13- *
14- * @return void
15- */
16- public function change () {
17-
18- $ exists = $ this ->hasTable ('metas ' );
19- if (!$ exists ) {
20-
21- $ table = $ this ->table ('metas ' );
22- $ table
23- ->addColumn ('rel_model ' , 'string ' , [
24- 'limit ' => '50 ' ,
25- 'null ' => true ,
26- 'default ' => '' ,
27- ])
28- ->addColumn ('rel_id ' , 'integer ' , [
29- 'limit ' => '11 ' ,
30- 'signed ' => '' ,
31- 'null ' => true ,
32- ])
33- ->addColumn ('name ' , 'string ' , [
34- 'limit ' => '256 ' ,
35- 'null ' => true ,
36- 'default ' => '' ,
37- ])
38- ->addColumn ('value ' , 'text ' , [
39- 'limit ' => '' ,
40- 'null ' => true ,
41- 'default ' => '' ,
42- ])
43- ->addColumn ('created ' , 'datetime ' , [
44- 'limit ' => '' ,
45- 'null ' => true ,
46- ])
47- ->addColumn ('modified ' , 'datetime ' , [
48- 'limit ' => '' ,
49- 'null ' => true ,
50- ])
51- ->save ();
52- }
53-
54- $ exists = $ this ->hasTable ('roles ' );
55- if (!$ exists ) {
56-
57-
58- $ table = $ this ->table ('roles ' );
59- $ table
60- ->addColumn ('name ' , 'string ' , [
61- 'limit ' => '50 ' ,
62- 'null ' => '' ,
63- 'default ' => '0 ' ,
64- ])
65- ->addColumn ('login_redirect ' , 'string ' , [
66- 'limit ' => '256 ' ,
67- 'null ' => true ,
68- 'default ' => '' ,
69- ])
70- ->addColumn ('created ' , 'datetime ' , [
71- 'limit ' => '' ,
72- 'null ' => '' ,
73- 'default ' => '0000-00-00 00:00:00 ' ,
74- ])
75- ->addColumn ('modified ' , 'datetime ' , [
76- 'limit ' => '' ,
77- 'null ' => '' ,
78- 'default ' => '0000-00-00 00:00:00 ' ,
79- ])
80- ->save ();
81- }
82-
83- $ exists = $ this ->hasTable ('users ' );
84- if (!$ exists ) {
85-
86-
87- $ table = $ this ->table ('users ' );
88- $ table
89- ->addColumn ('role_id ' , 'integer ' , [
90- 'limit ' => '11 ' ,
91- 'signed ' => '' ,
92- 'null ' => true ,
93- ])
94- ->addColumn ('email ' , 'string ' , [
95- 'limit ' => '255 ' ,
96- 'null ' => '' ,
97- 'default ' => '' ,
98- ])
99- ->addColumn ('password ' , 'string ' , [
100- 'limit ' => '255 ' ,
101- 'null ' => '' ,
102- 'default ' => '' ,
103- ])
104- ->addColumn ('created ' , 'datetime ' , [
105- 'limit ' => '' ,
106- 'null ' => true ,
107- 'default ' => '0000-00-00 00:00:00 ' ,
108- ])
109- ->addColumn ('modified ' , 'datetime ' , [
110- 'limit ' => '' ,
111- 'null ' => true ,
112- 'default ' => '0000-00-00 00:00:00 ' ,
113- ])
114- ->save ();
115- }
116- }
117-
1188 /**
1199 * Migrate Up.
12010 *
12111 * @return void
12212 */
12313 public function up () {
12414
15+ $ table = $ this ->table ('roles ' );
16+ $ table
17+ ->addColumn ('name ' , 'string ' , [
18+ 'limit ' => '50 ' ,
19+ 'null ' => '' ,
20+ 'default ' => '0 ' ,
21+ ])
22+ ->addColumn ('login_redirect ' , 'string ' , [
23+ 'limit ' => '256 ' ,
24+ 'null ' => true ,
25+ 'default ' => '' ,
26+ ])
27+ ->addColumn ('created ' , 'datetime ' , [
28+ 'limit ' => '' ,
29+ 'null ' => '' ,
30+ 'default ' => '0000-00-00 00:00:00 ' ,
31+ ])
32+ ->addColumn ('modified ' , 'datetime ' , [
33+ 'limit ' => '' ,
34+ 'null ' => '' ,
35+ 'default ' => '0000-00-00 00:00:00 ' ,
36+ ])
37+ ->create ();
38+
39+
40+ $ table = $ this ->table ('users ' );
41+ $ table
42+ ->addColumn ('role_id ' , 'integer ' , [
43+ 'limit ' => '11 ' ,
44+ 'signed ' => '' ,
45+ 'null ' => true ,
46+ ])
47+ ->addColumn ('email ' , 'string ' , [
48+ 'limit ' => '255 ' ,
49+ 'null ' => '' ,
50+ 'default ' => '' ,
51+ ])
52+ ->addColumn ('password ' , 'string ' , [
53+ 'limit ' => '255 ' ,
54+ 'null ' => '' ,
55+ 'default ' => '' ,
56+ ])
57+ ->addColumn ('created ' , 'datetime ' , [
58+ 'limit ' => '' ,
59+ 'null ' => true ,
60+ 'default ' => '0000-00-00 00:00:00 ' ,
61+ ])
62+ ->addColumn ('modified ' , 'datetime ' , [
63+ 'limit ' => '' ,
64+ 'null ' => true ,
65+ 'default ' => '0000-00-00 00:00:00 ' ,
66+ ])
67+ ->create ();
68+
69+ $ table = $ this ->table ('metas ' );
70+ $ table
71+ ->addColumn ('rel_model ' , 'string ' , [
72+ 'limit ' => '50 ' ,
73+ 'null ' => true ,
74+ 'default ' => '' ,
75+ ])
76+ ->addColumn ('rel_id ' , 'integer ' , [
77+ 'limit ' => '11 ' ,
78+ 'signed ' => '' ,
79+ 'null ' => true ,
80+ ])
81+ ->addColumn ('name ' , 'string ' , [
82+ 'limit ' => '256 ' ,
83+ 'null ' => true ,
84+ 'default ' => '' ,
85+ ])
86+ ->addColumn ('value ' , 'text ' , [
87+ 'limit ' => '' ,
88+ 'null ' => true ,
89+ 'default ' => '' ,
90+ ])
91+ ->addColumn ('created ' , 'datetime ' , [
92+ 'limit ' => '' ,
93+ 'null ' => true ,
94+ ])
95+ ->addColumn ('modified ' , 'datetime ' , [
96+ 'limit ' => '' ,
97+ 'null ' => true ,
98+ ])
99+ ->create ();
125100 }
126101
127102 /**
@@ -131,6 +106,11 @@ public function up() {
131106 */
132107 public function down () {
133108
109+ $ this ->dropTable ('users ' );
110+
111+ $ this ->dropTable ('roles ' );
112+
113+ $ this ->dropTable ('metas ' );
134114 }
135115
136116}
0 commit comments