Skip to content

Commit e6d9989

Browse files
committed
fix: Avoid different table schema when migration from older oc releases
Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent ae14806 commit e6d9989

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

lib/Migration/Version2060Date20200302131958.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,31 @@
99

1010
use Closure;
1111
use OCP\DB\ISchemaWrapper;
12+
use OCP\IDBConnection;
1213
use OCP\Migration\IOutput;
1314
use OCP\Migration\SimpleMigrationStep;
1415

1516
/**
1617
* Auto-generated migration step: Please modify to your needs!
1718
*/
1819
class Version2060Date20200302131958 extends SimpleMigrationStep {
20+
21+
public function __construct(
22+
private IDBConnection $connection,
23+
) {
24+
}
25+
26+
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
27+
/** @var ISchemaWrapper $schema */
28+
$schema = $schemaClosure();
29+
30+
if ($schema->hasTable('richdocuments_wopi')) {
31+
$qb = $this->connection->getQueryBuilder();
32+
$qb->delete('richdocuments_wopi');
33+
$qb->executeStatement();
34+
}
35+
}
36+
1937
/**
2038
* @param IOutput $output
2139
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
@@ -26,6 +44,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
2644
/** @var ISchemaWrapper $schema */
2745
$schema = $schemaClosure();
2846

47+
if ($schema->hasTable('richdocuments_wopi')) {
48+
$schema->dropTable('richdocuments_wopi');
49+
}
50+
2951
if (!$schema->hasTable('richdocuments_wopi')) {
3052
$table = $schema->createTable('richdocuments_wopi');
3153
$table->addColumn('id', 'bigint', [

0 commit comments

Comments
 (0)