aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/MigrationService.php
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2020-11-11 20:12:13 +0100
committerGitHub <noreply@github.com>2020-11-11 20:12:13 +0100
commitd7b5d4cb58f75e4598d3d537c743905c301d7952 (patch)
treeabd24ee9f49277b7eeb7766257986b1ae0978b18 /lib/private/DB/MigrationService.php
parentfec679dd8d38862b8039034b28d6deaf0d7ab51b (diff)
downloadnextcloud-server-d7b5d4cb58f75e4598d3d537c743905c301d7952.tar.gz
nextcloud-server-d7b5d4cb58f75e4598d3d537c743905c301d7952.zip
Revert "Revert "Installation goes brrrr""
Diffstat (limited to 'lib/private/DB/MigrationService.php')
-rw-r--r--lib/private/DB/MigrationService.php46
1 files changed, 46 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