fix(db): fix windows db migrator tests

- Ensure db files are closed before manipulating them
- Use contextlib.closing() so that sqlite connections are closed on existing the context
This commit is contained in:
psychedelicious@windows
2023-12-11 16:12:03 +11:00
committed by psychedelicious
parent 26ab917021
commit f1b6f78319
2 changed files with 15 additions and 10 deletions

View File

@ -190,12 +190,12 @@ class SQLiteMigrator:
self._run_migrations(temp_db_cursor)
# Close the connections, copy the original database as a backup, and move the temp database to the
# original database's path.
temp_db_conn.close()
self._conn.close()
backup_db_path = self._finalize_migration(
temp_db_path=temp_db_path,
original_db_path=self._db_path,
)
temp_db_conn.close()
self._conn.close()
self._logger.info(f"Migration successful. Original DB backed up to {backup_db_path}")
else:
# We are using a memory database. No special backup or special handling needed.