|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace OCA\Deck\Migration; |
| 6 | + |
| 7 | +use Closure; |
| 8 | +use OCP\DB\ISchemaWrapper; |
| 9 | +use OCP\Migration\IOutput; |
| 10 | +use OCP\Migration\SimpleMigrationStep; |
| 11 | + |
| 12 | +class Version10200Date20201111150114 extends SimpleMigrationStep { |
| 13 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
| 14 | + /** @var ISchemaWrapper $schema */ |
| 15 | + $schema = $schemaClosure(); |
| 16 | + |
| 17 | + // Fix wrong index added in Version1000Date20200308073933 |
| 18 | + $table = $schema->getTable('deck_assigned_users'); |
| 19 | + if ($table->hasIndex('deck_assigned_users_idx_t')) { |
| 20 | + $table->dropIndex('deck_assigned_users_idx_t'); |
| 21 | + if (!$table->hasIndex('deck_assigned_users_idx_ty')) { |
| 22 | + $table->addIndex(['type'], 'deck_assigned_users_idx_ty'); |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 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 | + } |
| 51 | + |
| 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; |
| 103 | + } |
| 104 | +} |
0 commit comments