From 1d1234d6ce61abd154bc9c77c836e496da07dcbe Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Mon, 4 Mar 2024 07:58:01 +0100 Subject: [PATCH] Use table prefix in metadata migration Signed-off-by: Louis Chemineau --- core/BackgroundJobs/MetadataMigrationJob.php | 5 ++++- lib/private/Repair/AddMetadataMigrationJob.php | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/BackgroundJobs/MetadataMigrationJob.php b/core/BackgroundJobs/MetadataMigrationJob.php index 0e88c31318ed1..98700d3df744f 100644 --- a/core/BackgroundJobs/MetadataMigrationJob.php +++ b/core/BackgroundJobs/MetadataMigrationJob.php @@ -29,6 +29,7 @@ use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\TimedJob; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\IConfig; use OCP\IDBConnection; // Migrate oc_file_metadata.metadata to oc_file_metadata.value. @@ -40,6 +41,7 @@ public function __construct( ITimeFactory $time, private IDBConnection $db, private IJobList $jobList, + private IConfig $config, ) { parent::__construct($time); @@ -48,7 +50,8 @@ public function __construct( } protected function run(mixed $argument): void { - if (!$this->db->createSchema()->getTable('oc_file_metadata')->hasColumn('metadata')) { + $prefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); + if (!$this->db->createSchema()->getTable($prefix.'file_metadata')->hasColumn('metadata')) { return; } diff --git a/lib/private/Repair/AddMetadataMigrationJob.php b/lib/private/Repair/AddMetadataMigrationJob.php index 7bc3573a1a276..1a4a813723719 100644 --- a/lib/private/Repair/AddMetadataMigrationJob.php +++ b/lib/private/Repair/AddMetadataMigrationJob.php @@ -24,6 +24,7 @@ use OC\Core\BackgroundJobs\MetadataMigrationJob; use OCP\BackgroundJob\IJobList; +use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; @@ -32,6 +33,7 @@ class AddMetadataMigrationJob implements IRepairStep { public function __construct( private IJobList $jobList, private IDBConnection $db, + private IConfig $config, ) { } @@ -41,7 +43,9 @@ public function getName() { public function run(IOutput $output) { $schema = $this->db->createSchema(); - $metadataTable = $schema->getTable('oc_file_metadata'); + + $prefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); + $metadataTable = $schema->getTable($prefix.'file_metadata'); if (!$metadataTable->hasColumn('metadata')) { return;