mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(db): invert backup/restore logic
Do the migration on a temp copy of the db, then back up the original and move the temp into its file.
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
from functools import partial
|
||||
from logging import Logger
|
||||
from pathlib import Path
|
||||
|
||||
from invokeai.app.services.shared.sqlite.migrations.migration_1 import migration_1
|
||||
from invokeai.app.services.shared.sqlite.migrations.migration_2 import migration_2
|
||||
@ -75,12 +76,22 @@ class ApiDependencies:
|
||||
image_files = DiskImageFileStorage(f"{output_folder}/images")
|
||||
|
||||
db = SqliteDatabase(config, logger)
|
||||
migrator = SQLiteMigrator(database=db.database, lock=db.lock, logger=logger)
|
||||
|
||||
migrator = SQLiteMigrator(
|
||||
db_path=db.database if isinstance(db.database, Path) else None,
|
||||
conn=db.conn,
|
||||
lock=db.lock,
|
||||
logger=logger,
|
||||
log_sql=config.log_sql,
|
||||
)
|
||||
migration_2.register_post_callback(partial(migrate_embedded_workflows, logger=logger, image_files=image_files))
|
||||
migrator.register_migration(migration_1)
|
||||
migrator.register_migration(migration_2)
|
||||
migrator.run_migrations()
|
||||
|
||||
if not db.is_memory:
|
||||
db.reinitialize()
|
||||
|
||||
configuration = config
|
||||
logger = logger
|
||||
|
||||
|
Reference in New Issue
Block a user