🐛 fix(utils.py): handle exception when running migrations to ignore "already exists" error and prevent unnecessary error logging and raising of RuntimeError
This commit is contained in:
parent
cb3fc079c6
commit
4320b127d3
1 changed files with 5 additions and 2 deletions
|
|
@ -33,8 +33,11 @@ def initialize_database():
|
|||
session.execute("DROP TABLE alembic_version")
|
||||
database_manager.run_migrations()
|
||||
except Exception as exc:
|
||||
logger.error(f"Error running migrations: {exc}")
|
||||
raise RuntimeError("Error running migrations") from exc
|
||||
# if the exception involves tables already existing
|
||||
# we can ignore it
|
||||
if "already exists" not in str(exc):
|
||||
logger.error(f"Error running migrations: {exc}")
|
||||
raise RuntimeError("Error running migrations") from exc
|
||||
database_manager.create_db_and_tables()
|
||||
logger.debug("Database initialized")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue