Selaa lähdekoodia

Merge pull request #10298 from nextcloud/bugfix/talk-714/only-migrate-the-schema-when-moving-database

Only create the schema when moving between databases
tags/v14.0.0beta1
Morris Jobke 5 vuotta sitten
vanhempi
commit
7da815bb04
No account linked to committer's email address
2 muutettua tiedostoa jossa 16 lisäystä ja 10 poistoa
  1. 1
    1
      core/Command/Db/ConvertType.php
  2. 15
    9
      lib/private/DB/MigrationService.php

+ 1
- 1
core/Command/Db/ConvertType.php Näytä tiedosto

@@ -245,7 +245,7 @@ class ConvertType extends Command implements CompletionAwareInterface {
$currentMigration = $fromMS->getMigration('current');
if ($currentMigration !== '0') {
$toMS = new MigrationService($app, $toDB);
$toMS->migrate($currentMigration);
$toMS->migrate($currentMigration, true);
}
}
}

+ 15
- 9
lib/private/DB/MigrationService.php Näytä tiedosto

@@ -376,13 +376,14 @@ class MigrationService {
* Applies all not yet applied versions up to $to
*
* @param string $to
* @param bool $schemaOnly
* @throws \InvalidArgumentException
*/
public function migrate($to = 'latest') {
public function migrate($to = 'latest', $schemaOnly = false) {
// read known migrations
$toBeExecuted = $this->getMigrationsToExecute($to);
foreach ($toBeExecuted as $version) {
$this->executeStep($version);
$this->executeStep($version, $schemaOnly);
}
}

@@ -432,14 +433,17 @@ class MigrationService {
* Executes one explicit version
*
* @param string $version
* @param bool $schemaOnly
* @throws \InvalidArgumentException
*/
public function executeStep($version) {
public function executeStep($version, $schemaOnly = false) {
$instance = $this->createInstance($version);

$instance->preSchemaChange($this->output, function() {
return new SchemaWrapper($this->connection);
}, ['tablePrefix' => $this->connection->getPrefix()]);
if (!$schemaOnly) {
$instance->preSchemaChange($this->output, function() {
return new SchemaWrapper($this->connection);
}, ['tablePrefix' => $this->connection->getPrefix()]);
}

$toSchema = $instance->changeSchema($this->output, function() {
return new SchemaWrapper($this->connection);
@@ -450,9 +454,11 @@ class MigrationService {
$toSchema->performDropTableCalls();
}

$instance->postSchemaChange($this->output, function() {
return new SchemaWrapper($this->connection);
}, ['tablePrefix' => $this->connection->getPrefix()]);
if (!$schemaOnly) {
$instance->postSchemaChange($this->output, function() {
return new SchemaWrapper($this->connection);
}, ['tablePrefix' => $this->connection->getPrefix()]);
}

$this->markAsExecuted($version);
}

Loading…
Peruuta
Tallenna