diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-11-20 15:02:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-20 15:02:51 +0100 |
commit | 691409cdec28f13db8205e1d13d624e2e9fb483a (patch) | |
tree | cb4ed0fc3da4e52bb5e9456ee86a592839b56e0f /lib/private/DB | |
parent | 7fd7601016ca08cfcb5ad7281310d9272de61509 (diff) | |
parent | 9a3ce2f71fffc166cf9676ee9231eb167d8954a4 (diff) | |
download | nextcloud-server-691409cdec28f13db8205e1d13d624e2e9fb483a.tar.gz nextcloud-server-691409cdec28f13db8205e1d13d624e2e9fb483a.zip |
Merge pull request #24062 from nextcloud/revert-24060-revert-24039-faster-installation
Revert "Revert "Installation goes brrrr""
Diffstat (limited to 'lib/private/DB')
-rw-r--r-- | lib/private/DB/MigrationService.php | 46 | ||||
-rw-r--r-- | lib/private/DB/SchemaWrapper.php | 1 |
2 files changed, 47 insertions, 0 deletions
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index cd0280162d3..9c94cbc61fa 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -124,6 +124,11 @@ class MigrationService { return false; } + if ($this->connection->tableExists('migrations')) { + $this->migrationTableCreated = true; + return false; + } + $schema = new SchemaWrapper($this->connection); /** @@ -408,6 +413,11 @@ class MigrationService { * @throws \InvalidArgumentException */ public function migrate($to = 'latest', $schemaOnly = false) { + if ($schemaOnly) { + $this->migrateSchemaOnly($to); + return; + } + // read known migrations $toBeExecuted = $this->getMigrationsToExecute($to); foreach ($toBeExecuted as $version) { @@ -416,6 +426,42 @@ class MigrationService { } /** + * Applies all not yet applied versions up to $to + * + * @param string $to + * @throws \InvalidArgumentException + */ + public function migrateSchemaOnly($to = 'latest') { + // read known migrations + $toBeExecuted = $this->getMigrationsToExecute($to); + + if (empty($toBeExecuted)) { + return; + } + + $toSchema = null; + foreach ($toBeExecuted as $version) { + $instance = $this->createInstance($version); + + $toSchema = $instance->changeSchema($this->output, function () use ($toSchema) { + return $toSchema ?: new SchemaWrapper($this->connection); + }, ['tablePrefix' => $this->connection->getPrefix()]) ?: $toSchema; + + $this->markAsExecuted($version); + } + + if ($toSchema instanceof SchemaWrapper) { + $targetSchema = $toSchema->getWrappedSchema(); + if ($this->checkOracle) { + $beforeSchema = $this->connection->createSchema(); + $this->ensureOracleIdentifierLengthLimit($beforeSchema, $targetSchema, strlen($this->connection->getPrefix())); + } + $this->connection->migrateToSchema($targetSchema); + $toSchema->performDropTableCalls(); + } + } + + /** * Get the human readable descriptions for the migration steps to run * * @param string $to diff --git a/lib/private/DB/SchemaWrapper.php b/lib/private/DB/SchemaWrapper.php index e42535d64ab..440008d35b3 100644 --- a/lib/private/DB/SchemaWrapper.php +++ b/lib/private/DB/SchemaWrapper.php @@ -111,6 +111,7 @@ class SchemaWrapper implements ISchemaWrapper { * @return \Doctrine\DBAL\Schema\Table */ public function createTable($tableName) { + unset($this->tablesToDelete[$tableName]); return $this->schema->createTable($this->connection->getPrefix() . $tableName); } |