🐛 fix(utils.py): improve error handling in initialize_database() function
The `initialize_database()` function now handles two specific exceptions: "overlaps with other requested revisions" and "Can't locate revision identified by". If either of these exceptions occur, they will not be raised and instead the `alembic_version` table will be deleted. This change improves the error handling and ensures that the database is properly initialized.
This commit is contained in:
parent
82ad45847f
commit
61a5c9dcdb
1 changed files with 5 additions and 1 deletions
|
|
@ -32,7 +32,11 @@ def initialize_database():
|
|||
try:
|
||||
database_service.run_migrations()
|
||||
except CommandError as exc:
|
||||
if "Can't locate revision identified by" not in str(exc):
|
||||
# if "overlaps with other requested revisions" or "Can't locate revision identified by"
|
||||
# are not in the exception, we can't handle it
|
||||
if "overlaps with other requested revisions" not in str(
|
||||
exc
|
||||
) and "Can't locate revision identified by" not in str(exc):
|
||||
raise exc
|
||||
# This means there's wrong revision in the DB
|
||||
# We need to delete the alembic_version table
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue