Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] Use table prefix in metadata migration #43971

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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->getSystemValueString('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->getSystemValueString('dbtableprefix', 'oc_');
$metadataTable = $schema->getTable($prefix.'file_metadata');

if (!$metadataTable->hasColumn('metadata')) {
return;
Expand Down
Loading