Skip to content

Commit c1dfbac

Browse files
authored
Merge pull request #4225 from nextcloud/fix/migration-7-to-8
Fix migration from 7.x to 8.x
2 parents deeddd8 + 529740f commit c1dfbac

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

lib/Db/V2/TableManager.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,24 @@ public function fixNullishShares(): array {
463463
$messages = [];
464464
$query = $this->connection->getQueryBuilder();
465465

466-
// replace all nullish group_ids with 0 in share table
467-
$query->update(Share::TABLE)
468-
->set('group_id', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
469-
->where($query->expr()->isNull('group_id'));
466+
if (!$this->schema->hasTable(Share::TABLE)) {
467+
$messages[] = 'Table ' . Share::TABLE . ' does not exist';
468+
return $messages;
469+
}
470470

471-
$count = $query->executeStatement();
471+
$table = $this->schema->getTable(Share::TABLE);
472472

473-
if ($count > 0) {
474-
$messages[] = 'Updated ' . $count . ' shares and set group_id to 0 for nullish values';
473+
if ($table->hasColumn('group_id')) {
474+
// replace all nullish group_ids with 0 in share table
475+
$query->update(Share::TABLE)
476+
->set('group_id', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
477+
->where($query->expr()->isNull('group_id'));
478+
479+
$count = $query->executeStatement();
480+
481+
if ($count > 0) {
482+
$messages[] = 'Updated ' . $count . ' shares and set group_id to 0 for nullish values';
483+
}
475484
}
476485

477486
// replace all nullish poll_id with 0 in share table

lib/Migration/Version080300Date20250816201201.php renamed to lib/Migration/Version080301Date20250822153002.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @psalm-suppress UnusedClass
2626
*/
27-
class Version080300Date20250816201201 extends SimpleMigrationStep {
27+
class Version080301Date20250822153002 extends SimpleMigrationStep {
2828
private ISchemaWrapper $schema;
2929
private ?IOutput $output = null;
3030

0 commit comments

Comments
 (0)