22
22
$ table ->addColumn ('data ' , 'json_array ' , ['notnull ' => false ]);
23
23
$ table ->addColumn ('roles ' , 'simple_array ' , ['notnull ' => false ]);
24
24
$ table ->setPrimaryKey (['id ' ]);
25
- $ table ->addUniqueIndex (['slug ' ], 'BLOG_POST_SLUG ' );
26
- $ table ->addIndex (['title ' ], 'BLOG_POST_TITLE ' );
27
- $ table ->addIndex (['user_id ' ], 'BLOG_POST_USER_ID ' );
28
- $ table ->addIndex (['date ' ], 'BLOG_POST_DATE ' );
25
+ $ table ->addUniqueIndex (['slug ' ], '@ BLOG_POST_SLUG ' );
26
+ $ table ->addIndex (['title ' ], '@ BLOG_POST_TITLE ' );
27
+ $ table ->addIndex (['user_id ' ], '@ BLOG_POST_USER_ID ' );
28
+ $ table ->addIndex (['date ' ], '@ BLOG_POST_DATE ' );
29
29
});
30
30
}
31
31
43
43
$ table ->addColumn ('content ' , 'text ' );
44
44
$ table ->addColumn ('status ' , 'smallint ' );
45
45
$ table ->setPrimaryKey (['id ' ]);
46
- $ table ->addIndex (['author ' ], 'BLOG_COMMENT_AUTHOR ' );
47
- $ table ->addIndex (['created ' ], 'BLOG_COMMENT_CREATED ' );
48
- $ table ->addIndex (['status ' ], 'BLOG_COMMENT_STATUS ' );
49
- $ table ->addIndex (['post_id ' ], 'BLOG_COMMENT_POST_ID ' );
50
- $ table ->addIndex (['post_id ' , 'status ' ], 'BLOG_COMMENT_POST_ID_STATUS ' );
46
+ $ table ->addIndex (['author ' ], '@ BLOG_COMMENT_AUTHOR ' );
47
+ $ table ->addIndex (['created ' ], '@ BLOG_COMMENT_CREATED ' );
48
+ $ table ->addIndex (['status ' ], '@ BLOG_COMMENT_STATUS ' );
49
+ $ table ->addIndex (['post_id ' ], '@ BLOG_COMMENT_POST_ID ' );
50
+ $ table ->addIndex (['post_id ' , 'status ' ], '@ BLOG_COMMENT_POST_ID_STATUS ' );
51
51
});
52
52
}
53
53
64
64
if ($ util ->tableExists ('@blog_comment ' )) {
65
65
$ util ->dropTable ('@blog_comment ' );
66
66
}
67
- }
67
+ },
68
+
69
+ 'updates ' => [
70
+
71
+ '0.11.2 ' => function ($ app ) {
72
+
73
+ $ db = $ app ['db ' ];
74
+ $ util = $ db ->getUtility ();
75
+
76
+ foreach (['@blog_post ' , '@blog_comment ' ] as $ name ) {
77
+ $ table = $ util ->getTable ($ name );
78
+
79
+ foreach ($ table ->getIndexes () as $ name => $ index ) {
80
+ if ($ name !== 'primary ' ) {
81
+ $ table ->renameIndex ($ index ->getName (), $ app ['db ' ]->getPrefix () . $ index ->getName ());
82
+ }
83
+ }
84
+
85
+ if ($ app ['db ' ]->getDatabasePlatform ()->getName () === 'sqlite ' ) {
86
+ foreach ($ table ->getColumns () as $ column ) {
87
+ if (in_array ($ column ->getType ()->getName (), ['string ' , 'text ' ])) {
88
+ $ column ->setOptions (['customSchemaOptions ' => ['collation ' => 'NOCASE ' ]]);
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ $ util ->migrate ();
95
+ }
96
+
97
+ ]
68
98
69
99
];
0 commit comments