diff --git a/lib/Db/V2/TableManager.php b/lib/Db/V2/TableManager.php index f5ce629ec2..6f8bc89ed8 100644 --- a/lib/Db/V2/TableManager.php +++ b/lib/Db/V2/TableManager.php @@ -463,15 +463,24 @@ public function fixNullishShares(): array { $messages = []; $query = $this->connection->getQueryBuilder(); - // replace all nullish group_ids with 0 in share table - $query->update(Share::TABLE) - ->set('group_id', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)) - ->where($query->expr()->isNull('group_id')); + if (!$this->schema->hasTable(Share::TABLE)) { + $messages[] = 'Table ' . Share::TABLE . ' does not exist'; + return $messages; + } - $count = $query->executeStatement(); + $table = $this->schema->getTable(Share::TABLE); - if ($count > 0) { - $messages[] = 'Updated ' . $count . ' shares and set group_id to 0 for nullish values'; + if ($table->hasColumn('group_id')) { + // replace all nullish group_ids with 0 in share table + $query->update(Share::TABLE) + ->set('group_id', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)) + ->where($query->expr()->isNull('group_id')); + + $count = $query->executeStatement(); + + if ($count > 0) { + $messages[] = 'Updated ' . $count . ' shares and set group_id to 0 for nullish values'; + } } // replace all nullish poll_id with 0 in share table diff --git a/lib/Migration/Version080300Date20250816201201.php b/lib/Migration/Version080301Date20250822153002.php similarity index 98% rename from lib/Migration/Version080300Date20250816201201.php rename to lib/Migration/Version080301Date20250822153002.php index 602f1db2f6..8b8419cbaf 100644 --- a/lib/Migration/Version080300Date20250816201201.php +++ b/lib/Migration/Version080301Date20250822153002.php @@ -24,7 +24,7 @@ * * @psalm-suppress UnusedClass */ -class Version080300Date20250816201201 extends SimpleMigrationStep { +class Version080301Date20250822153002 extends SimpleMigrationStep { private ISchemaWrapper $schema; private ?IOutput $output = null;