@@ -562,44 +562,44 @@ def open_sqlite_library(
562562 # a library that doesn't yet have the is_hidden property on the tags table
563563 make_tables (self .engine )
564564
565- with Session (self .engine ) as session :
566- # save backup if patches will be applied
567- if loaded_db_version < DB_VERSION :
568- self .library_dir = library_dir
569- self .save_library_backup_to_disk ()
570- self .library_dir = None
571-
572- # migrate DB step by step from one version to the next
573- # (migration_method, db_version, initial_db_version)
574- migrations = [
575- (self .__apply_db7_migration , 7 , None ), # changes: value_type, tags
576- (self .__apply_db8_migration , 8 , None ), # changes: tag_colors
577- (self .__apply_db9_migration , 9 , None ), # changes: entries
578- (self .__apply_db100_migration , 100 , None ), # changes: tag_parents
579- (self .__apply_db101_migration , 101 , None ), # changes: versions
580- (self .__apply_db102_migration , 102 , None ), # changes: tag_parents
581- (self .__apply_db103_migration , 103 , None ), # changes: tags
582- (self .__apply_db104_migration , 104 , None ), # changes: deletes preferences
583- (self .__apply_db200_migration , 200 , None ), # changes: field tables
584- (self .__apply_db201_migration , 201 , 200 ), # changes: field tables
585- (self .__apply_db202_migration , 202 , None ), # changes: tag_parents
586- ]
587- for migration , v , iv in migrations :
588- if loaded_db_version < v and (iv is None or initial_db_version < iv ):
589- logger .info (f"[Library][Migration][{ v } ] Starting DB Migration" )
590- with session :
591- # any error causes transaction to rollback
592- migration (session , library_dir )
593- loaded_db_version = v
594- self .set_version (session , DB_VERSION_CURRENT_KEY , v )
595- session .commit ()
596- logger .info (f"[Library][Migration][{ v } ] Completed DB Migration" )
597-
598- assert loaded_db_version == DB_VERSION , (
599- "Ran all migrations, but the DB is still not on the newest version"
600- )
601- logger .info (f"[Library] Library migrated to DB version { DB_VERSION } " )
565+ # save backup if patches will be applied
566+ if loaded_db_version < DB_VERSION :
567+ self .library_dir = library_dir
568+ self .save_library_backup_to_disk ()
569+ self .library_dir = None
570+
571+ # migrate DB step by step from one version to the next
572+ # (migration_method, db_version, initial_db_version)
573+ migrations = [
574+ (self .__apply_db7_migration , 7 , None ), # changes: value_type, tags
575+ (self .__apply_db8_migration , 8 , None ), # changes: tag_colors
576+ (self .__apply_db9_migration , 9 , None ), # changes: entries
577+ (self .__apply_db100_migration , 100 , None ), # changes: tag_parents
578+ (self .__apply_db101_migration , 101 , None ), # changes: versions
579+ (self .__apply_db102_migration , 102 , None ), # changes: tag_parents
580+ (self .__apply_db103_migration , 103 , None ), # changes: tags
581+ (self .__apply_db104_migration , 104 , None ), # changes: deletes preferences
582+ (self .__apply_db200_migration , 200 , None ), # changes: field tables
583+ (self .__apply_db201_migration , 201 , 200 ), # changes: field tables
584+ (self .__apply_db202_migration , 202 , None ), # changes: tag_parents
585+ ]
586+ for migration , v , iv in migrations :
587+ if loaded_db_version < v and (iv is None or initial_db_version < iv ):
588+ logger .info (f"[Library][Migration][{ v } ] Starting DB Migration" )
589+ with Session (self .engine ) as session :
590+ # any error causes transaction to rollback
591+ migration (session , library_dir )
592+ loaded_db_version = v
593+ self .set_version (session , DB_VERSION_CURRENT_KEY , v )
594+ session .commit ()
595+ logger .info (f"[Library][Migration][{ v } ] Completed DB Migration" )
596+
597+ assert loaded_db_version == DB_VERSION , (
598+ "Ran all migrations, but the DB is still not on the newest version"
599+ )
600+ logger .info (f"[Library] Library migrated to DB version { DB_VERSION } " )
602601
602+ with Session (self .engine ) as session :
603603 # check if folder matching current path exists already
604604 # NOTE: this has been causing new Folders to be created when the library is moved, since
605605 # its introduction
0 commit comments