Skip to content

Commit

Permalink
Use table prefix in metadata migration
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Mar 4, 2024
1 parent 0045e76 commit 1d1234d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion core/BackgroundJobs/MetadataMigrationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -40,6 +41,7 @@ public function __construct(
ITimeFactory $time,
private IDBConnection $db,
private IJobList $jobList,
private IConfig $config,
) {
parent::__construct($time);

Expand All @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion lib/private/Repair/AddMetadataMigrationJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,6 +33,7 @@ class AddMetadataMigrationJob implements IRepairStep {
public function __construct(
private IJobList $jobList,
private IDBConnection $db,
private IConfig $config,
) {
}

Expand All @@ -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;
Expand Down

0 comments on commit 1d1234d

Please sign in to comment.