diff --git a/lib/Migration/Version18003Date20260616000000.php b/lib/Migration/Version18003Date20260616000000.php new file mode 100644 index 0000000000..658f5c143b --- /dev/null +++ b/lib/Migration/Version18003Date20260616000000.php @@ -0,0 +1,63 @@ +connection->getQueryBuilder(); + $qb->delete('libresign_user_element') + ->where($qb->expr()->isNull('node_id')); + $deleted = $qb->executeStatement(); + if ($deleted > 0) { + $output->warning(sprintf( + 'Deleted %d row(s) from libresign_user_element with NULL node_id (corrupted rows with no associated file).', + $deleted, + )); + } + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + * @return ISchemaWrapper|null + */ + #[\Override] + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->getTable('libresign_user_element'); + $column = $table->getColumn('node_id'); + if ($column->getNotnull()) { + return null; + } + + $column->setNotnull(true); + return $schema; + } +}