staging #447

Merged
edraft merged 56 commits from staging into master 2023-12-02 19:34:25 +01:00
Showing only changes of commit 06a0eba5c5 - Show all commits

View File

@ -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)