#428 #436
@ -37,6 +37,22 @@ class MigrationService:
|
||||
|
||||
return applied_migrations
|
||||
|
||||
def _migration_migrations_to_old(self, migration: MigrationHistory):
|
||||
if migration.migration_id.endswith("Migration"):
|
||||
return
|
||||
|
||||
self._logger.debug(__name__, f"Migrate old migration {migration.migration_id} to new method")
|
||||
|
||||
self._cursor.execute(migration.change_id_string(f"{migration.migration_id}Migration"))
|
||||
self._db.save_changes()
|
||||
|
||||
def _migration_migrations_to_new(self, migration: MigrationHistory):
|
||||
if not migration.migration_id.endswith("Migration"):
|
||||
return
|
||||
|
||||
self._logger.debug(__name__, f"Migrate old migration {migration.migration_id} to new method")
|
||||
self._cursor.execute(migration.change_id_string(migration.migration_id.replace("Migration", "")))
|
||||
self._db.save_changes()
|
||||
|
||||
def _migrate_from_old_to_new(self):
|
||||
self._cursor.execute("SHOW TABLES LIKE 'MigrationHistory'")
|
||||
result = self._cursor.fetchone()
|
||||
@ -44,12 +60,10 @@ class MigrationService:
|
||||
return
|
||||
|
||||
for migration in self._get_migration_history():
|
||||
if not migration.migration_id.endswith("Migration"):
|
||||
continue
|
||||
|
||||
self._logger.debug(__name__, f"Migrate old migration {migration.migration_id} to new method")
|
||||
self._cursor.execute(migration.change_id_string(migration.migration_id.replace("Migration", "")))
|
||||
self._db.save_changes()
|
||||
if version.Version(bot.__version__) < version.Version("1.2.2"):
|
||||
self._migration_migrations_to_old(migration)
|
||||
else:
|
||||
self._migration_migrations_to_new(migration)
|
||||
|
||||
def _load_scripts(self, upgrade: bool = True) -> List[Migration]:
|
||||
migrations = List(Migration)
|
||||
|
Loading…
Reference in New Issue
Block a user
Sollte hier nicht vielleicht die Nachricht
"Migrate new migration {migration.migration_id} to old method"
geloggt werden?Jedenfalls steht in Zeile 52 die selbe Nachricht drinne.