summaryrefslogtreecommitdiffstats
path: root/lib/private/DB
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-11-20 15:02:51 +0100
committerGitHub <noreply@github.com>2020-11-20 15:02:51 +0100
commit691409cdec28f13db8205e1d13d624e2e9fb483a (patch)
treecb4ed0fc3da4e52bb5e9456ee86a592839b56e0f /lib/private/DB
parent7fd7601016ca08cfcb5ad7281310d9272de61509 (diff)
parent9a3ce2f71fffc166cf9676ee9231eb167d8954a4 (diff)
downloadnextcloud-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.php46
-rw-r--r--lib/private/DB/SchemaWrapper.php1
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);
}