diff --git a/db/migrations/1.259_migrations_reloaded.php b/db/migrations/1.259_migrations_reloaded.php index b73de5c327922d7003c10269e8f884f31b29fcec..1ffb583d4c7d8748c1b2e417ead2426daa74da05 100644 --- a/db/migrations/1.259_migrations_reloaded.php +++ b/db/migrations/1.259_migrations_reloaded.php @@ -17,6 +17,9 @@ class MigrationsReloaded extends Migration DROP PRIMARY KEY, ADD PRIMARY KEY (domain, branch)"; $db->exec($sql); + + $sql = "UPDATE schema_version SET branch = '1' WHERE domain = 'studip'"; + $db->exec($sql); } public function down() diff --git a/lib/migrations/DBSchemaVersion.php b/lib/migrations/DBSchemaVersion.php index 61894be078755cf46cf40bfac2c0bbb81b3aa035..4c723dc18005102b258ad524d0464416bcc189d2 100644 --- a/lib/migrations/DBSchemaVersion.php +++ b/lib/migrations/DBSchemaVersion.php @@ -157,7 +157,8 @@ class DBSchemaVersion implements SchemaVersion } /** - * Validate correct structure of schema_version table. + * Validate correct structure of schema_version table. This + * will upgrade the schema from 4.4 style to 5.1 if necessary. */ private function validateSchemaVersion() { @@ -170,10 +171,12 @@ class DBSchemaVersion implements SchemaVersion 20201002, 20201103, 202011031, 20210317 ]; + // drop backported migrations $query = "DELETE FROM schema_versions WHERE domain = 'studip' AND version in (?)"; $db->execute($query, [$backported_migrations]); + // drop migrations with irregular numbers $query = "DELETE FROM schema_versions WHERE domain = 'studip' AND LENGTH(version) > 8"; $db->exec($query);