From d7b5d4cb58f75e4598d3d537c743905c301d7952 Mon Sep 17 00:00:00 2001 From: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Date: Wed, 11 Nov 2020 20:12:13 +0100 Subject: Revert "Revert "Installation goes brrrr"" --- lib/private/DB/MigrationService.php | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'lib/private/DB') 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) { @@ -415,6 +425,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 * -- cgit v1.2.3 From 9a3ce2f71fffc166cf9676ee9231eb167d8954a4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 16 Nov 2020 19:34:38 +0100 Subject: Don't drop the table anymore when we create it again Signed-off-by: Joas Schilling --- lib/private/DB/SchemaWrapper.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/private/DB') 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); } -- cgit v1.2.3