1010use OCP \Migration \SimpleMigrationStep ;
1111
1212class Version10200Date20201111150114 extends SimpleMigrationStep {
13-
14-
15- function preSchemaChange (IOutput $ output , Closure $ schemaClosure , array $ options ): void {
16- }
17-
1813 public function changeSchema (IOutput $ output , Closure $ schemaClosure , array $ options ): ?ISchemaWrapper {
1914 /** @var ISchemaWrapper $schema */
2015 $ schema = $ schemaClosure ();
@@ -28,9 +23,82 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
2823 }
2924 }
3025
31- return $ schema ;
32- }
26+ // Check consistency of the labels table when updating from a version < 0.6
27+ // git commit for database.xml change at b0eaae6705dbfb9ce834d4047912d3e34eaa157f
28+ $ table = $ schema ->getTable ('deck_labels ' );
29+ if (!$ table ->hasColumn ('last_modified ' )) {
30+ $ table ->addColumn ('last_modified ' , 'integer ' , [
31+ 'notnull ' => false ,
32+ 'default ' => 0 ,
33+ 'unsigned ' => true ,
34+ ]);
35+ }
36+
37+ // Check consistency of the cards table when updating from a version < 0.5.1
38+ // git commit for database.xml change at dd104466d61e32f59552da183034522e04effe35
39+ $ table = $ schema ->getTable ('deck_cards ' );
40+ if (!$ table ->hasColumn ('description_prev ' )) {
41+ $ table ->addColumn ('description_prev ' , 'text ' , [
42+ 'notnull ' => false ,
43+ ]);
44+ }
45+ if (!$ table ->hasColumn ('last_editor ' )) {
46+ $ table ->addColumn ('last_editor ' , 'string ' , [
47+ 'notnull ' => false ,
48+ 'length ' => 64 ,
49+ ]);
50+ }
3351
34- public function postSchemaChange (IOutput $ output , Closure $ schemaClosure , array $ options ): void {
52+ // Check consistency of the cards table when updating from a version < 0.5.0
53+ // git commit for database.xml change at a068d6e1c6588662f0ea131e57f974238538eda6
54+ $ table = $ schema ->getTable ('deck_boards ' );
55+ if (!$ table ->hasColumn ('last_modified ' )) {
56+ $ table ->addColumn ('last_modified ' , 'integer ' , [
57+ 'notnull ' => false ,
58+ 'default ' => 0 ,
59+ 'unsigned ' => true ,
60+ ]);
61+ }
62+ $ table = $ schema ->getTable ('deck_stacks ' );
63+ if (!$ table ->hasColumn ('last_modified ' )) {
64+ $ table ->addColumn ('last_modified ' , 'integer ' , [
65+ 'notnull ' => false ,
66+ 'default ' => 0 ,
67+ 'unsigned ' => true ,
68+ ]);
69+ }
70+
71+ // Check consistency of the cards table when updating from a version < 0.5.0
72+ // git commit for database.xml change at ef4ce31c47a5ef70d1a4d00f2d4cd182ac067f2c
73+ $ table = $ schema ->getTable ('deck_stacks ' );
74+ if (!$ table ->hasColumn ('deleted_at ' )) {
75+ $ table ->addColumn ('deleted_at ' , 'bigint ' , [
76+ 'notnull ' => false ,
77+ 'length ' => 8 ,
78+ 'default ' => 0 ,
79+ 'unsigned ' => true ,
80+ ]);
81+ }
82+
83+ // Check consistency of the cards table when updating from a version < 0.5.0
84+ // git commit for database.xml change at 2ef4b55af427d90412544e77916e9449db7dbbcd
85+ $ table = $ schema ->getTable ('deck_cards ' );
86+ if (!$ table ->hasColumn ('deleted_at ' )) {
87+ $ table ->addColumn ('deleted_at ' , 'bigint ' , [
88+ 'notnull ' => false ,
89+ 'length ' => 8 ,
90+ 'default ' => 0 ,
91+ 'unsigned ' => true ,
92+ ]);
93+ }
94+
95+ $ table = $ schema ->getTable ('deck_cards ' );
96+ if ($ table ->getColumn ('title ' )->getLength () !== 255 ) {
97+ $ table ->changeColumn ('title ' , [
98+ 'length ' => 255
99+ ]);
100+ }
101+
102+ return $ schema ;
35103 }
36104}
0 commit comments