Skip to content

Commit 054d3f5

Browse files
committed
fix(db): Adapt migrations to new OCP\DB\Schema
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 9517b0f commit 054d3f5

10 files changed

Lines changed: 20 additions & 32 deletions

File tree

apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace OCA\FederatedFileSharing\Migration;
1111

1212
use Closure;
13-
use Doctrine\DBAL\Types\Type;
1413
use OCP\DB\ISchemaWrapper;
1514
use OCP\DB\Types;
1615
use OCP\IDBConnection;
@@ -32,9 +31,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
3231
if ($schema->hasTable('federated_reshares')) {
3332
$table = $schema->getTable('federated_reshares');
3433
$remoteIdColumn = $table->getColumn('remote_id');
35-
if ($remoteIdColumn && Type::lookupName($remoteIdColumn->getType()) !== Types::STRING) {
34+
if ($remoteIdColumn->getType()->getName() !== Types::STRING) {
3635
$remoteIdColumn->setNotnull(false);
37-
$remoteIdColumn->setType(Type::getType(Types::STRING));
36+
$remoteIdColumn->setType(Types::STRING);
3837
$remoteIdColumn->setOptions(['length' => 255]);
3938
$remoteIdColumn->setDefault('');
4039
return $schema;

apps/files_sharing/lib/Migration/Version11300Date20201120141438.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace OCA\Files_Sharing\Migration;
1111

1212
use Closure;
13-
use Doctrine\DBAL\Types\Type;
1413
use OCP\DB\ISchemaWrapper;
1514
use OCP\DB\Types;
1615
use OCP\IDBConnection;
@@ -91,9 +90,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
9190
} else {
9291
$table = $schema->getTable('share_external');
9392
$remoteIdColumn = $table->getColumn('remote_id');
94-
if ($remoteIdColumn && Type::lookupName($remoteIdColumn->getType()) !== Types::STRING) {
93+
if ($remoteIdColumn->getType()->getName() !== Types::STRING) {
9594
$remoteIdColumn->setNotnull(false);
96-
$remoteIdColumn->setType(Type::getType(Types::STRING));
95+
$remoteIdColumn->setType(Types::STRING);
9796
$remoteIdColumn->setOptions(['length' => 255]);
9897
$remoteIdColumn->setDefault('');
9998
}

apps/settings/lib/SetupChecks/DatabasePendingBigIntConversions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
namespace OCA\Settings\SetupChecks;
1111

12-
use Doctrine\DBAL\Types\BigIntType;
1312
use OC\Core\Command\Db\ConvertFilecacheBigInt;
1413
use OC\DB\Connection;
1514
use OC\DB\SchemaWrapper;
15+
use OCP\DB\Types;
1616
use OCP\EventDispatcher\IEventDispatcher;
1717
use OCP\IDBConnection;
1818
use OCP\IL10N;
@@ -57,7 +57,7 @@ protected function getBigIntConversionPendingColumns(): array {
5757
$column = $table->getColumn($columnName);
5858
$isAutoIncrement = $column->getAutoincrement();
5959
$isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
60-
if (!($column->getType() instanceof BigIntType) && !$isAutoIncrementOnSqlite) {
60+
if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
6161
$pendingColumns[] = $tableName . '.' . $columnName;
6262
}
6363
}

apps/twofactor_backupcodes/lib/Migration/Version1002Date20170919123342.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99

1010
namespace OCA\TwoFactorBackupCodes\Migration;
1111

12-
use Doctrine\DBAL\Types\Type;
13-
use Doctrine\DBAL\Types\Types;
1412
use OCP\DB\ISchemaWrapper;
13+
use OCP\DB\Types;
1514
use OCP\Migration\IOutput;
1615
use OCP\Migration\SimpleMigrationStep;
1716

@@ -35,7 +34,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
3534

3635
$column = $table->getColumn('used');
3736
if ($column->getType()->getName() !== Types::SMALLINT) {
38-
$column->setType(Type::getType(Types::SMALLINT));
37+
$column->setType(Types::SMALLINT);
3938
$column->setOptions(['length' => 6]);
4039
}
4140

apps/workflowengine/lib/Migration/Version2000Date20190808074233.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
namespace OCA\WorkflowEngine\Migration;
1111

1212
use Closure;
13-
use Doctrine\DBAL\Schema\Table;
1413
use OCA\WorkflowEngine\Entity\File;
1514
use OCP\DB\ISchemaWrapper;
15+
use OCP\DB\Schema\ITable;
1616
use OCP\DB\Types;
1717
use OCP\Migration\IOutput;
1818
use OCP\Migration\SimpleMigrationStep;
@@ -118,7 +118,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
118118
return $schema;
119119
}
120120

121-
protected function ensureEntityColumns(Table $table) {
121+
protected function ensureEntityColumns(ITable $table): void {
122122
if (!$table->hasColumn('entity')) {
123123
$table->addColumn('entity', Types::STRING, [
124124
'notnull' => true,

build/psalm-baseline.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,11 +2669,6 @@
26692669
<code><![CDATA[$svg]]></code>
26702670
</NullableReturnStatement>
26712671
</file>
2672-
<file src="apps/twofactor_backupcodes/lib/Migration/Version1002Date20170919123342.php">
2673-
<DeprecatedMethod>
2674-
<code><![CDATA[getName]]></code>
2675-
</DeprecatedMethod>
2676-
</file>
26772672
<file src="apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php">
26782673
<DeprecatedMethod>
26792674
<code><![CDATA[generate]]></code>

core/Command/Db/ConvertFilecacheBigInt.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace OC\Core\Command\Db;
99

10-
use Doctrine\DBAL\Types\Type;
1110
use OC\DB\Connection;
1211
use OC\DB\SchemaWrapper;
1312
use OCP\DB\Types;
@@ -73,8 +72,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7372
$column = $table->getColumn($columnName);
7473
$isAutoIncrement = $column->getAutoincrement();
7574
$isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
76-
if (Type::lookupName($column->getType()) !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
77-
$column->setType(Type::getType(Types::BIGINT));
75+
if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
76+
$column->setType(Types::BIGINT);
7877
$column->setOptions(['length' => 20]);
7978

8079
$updates[] = '* ' . $tableName . '.' . $columnName;

core/Migrations/Version34000Date20260318095645.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace OC\Core\Migrations;
1111

1212
use Closure;
13-
use Doctrine\DBAL\Types\Type;
1413
use OCP\DB\ISchemaWrapper;
1514
use OCP\DB\Types;
1615
use OCP\Migration\Attributes\ColumnType;
@@ -30,8 +29,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
3029
$table = $schema->getTable('jobs');
3130
$argumentColumn = $table->getColumn('argument');
3231

33-
if ($argumentColumn->getType() !== Type::getType(Types::TEXT)) {
34-
$argumentColumn->setType(Type::getType(Types::TEXT));
32+
if ($argumentColumn->getType()->getName() !== Types::TEXT) {
33+
$argumentColumn->setType(Types::TEXT);
3534
return $schema;
3635
}
3736
}

lib/private/Repair/Owncloud/MigratePropertiesTable.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
namespace OC\Repair\Owncloud;
1111

12-
use Doctrine\DBAL\Types\StringType;
13-
use Doctrine\DBAL\Types\Type;
1412
use OC\DB\Connection;
1513
use OC\DB\SchemaWrapper;
14+
use OCP\DB\Types;
1615
use OCP\Migration\IOutput;
1716
use OCP\Migration\IRepairStep;
1817

@@ -39,8 +38,8 @@ public function run(IOutput $output): void {
3938
$output->info('Update the oc_properties table schema.');
4039
$table = $schema->getTable('oc_properties');
4140
$column = $table->getColumn('propertyvalue');
42-
if ($column->getType() instanceof StringType) {
43-
$column->setType(Type::getType('text'));
41+
if ($column->getType()->getName() === Types::STRING) {
42+
$column->setType(Types::TEXT);
4443
$column->setLength(null);
4544
}
4645

lib/public/Migration/BigIntMigration.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
namespace OCP\Migration;
99

10-
use Doctrine\DBAL\Types\Type;
11-
use Doctrine\DBAL\Types\Types;
1210
use OCP\DB\ISchemaWrapper;
11+
use OCP\DB\Types;
1312

1413
/**
1514
* @since 13.0.0
@@ -41,8 +40,8 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
4140

4241
foreach ($columns as $columnName) {
4342
$column = $table->getColumn($columnName);
44-
if (Type::lookupName($column->getType()) !== Types::BIGINT) {
45-
$column->setType(Type::getType(Types::BIGINT));
43+
if ($column->getType()->getName() !== Types::BIGINT) {
44+
$column->setType(Types::BIGINT);
4645
$column->setOptions(['length' => 20]);
4746
}
4847
}

0 commit comments

Comments
 (0)