Fix migration error and initialize database in
utils.py
This commit is contained in:
parent
8f04139ddd
commit
dcefb8363c
3 changed files with 9 additions and 4 deletions
|
|
@ -155,7 +155,7 @@ class DatabaseService(Service):
|
|||
command.check(alembic_cfg)
|
||||
except util.exc.AutogenerateDiffsDetected as exc:
|
||||
logger.exception("AutogenerateDiffsDetected: {exc}")
|
||||
logger.warning("Something went wrong running migrations. Please, run `langflow migration --fix`")
|
||||
raise RuntimeError("Something went wrong running migrations. Please, run `langflow migration --fix`")
|
||||
|
||||
if fix:
|
||||
self.try_downgrade_upgrade_until_success(alembic_cfg)
|
||||
|
|
|
|||
|
|
@ -48,8 +48,9 @@ def initialize_database(fix_migration: bool = False):
|
|||
# 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
|
||||
logger.error(exc)
|
||||
|
||||
raise exc
|
||||
logger.debug("Database initialized")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,11 @@ def initialize_services(fix_migration: bool = False):
|
|||
# Test cache connection
|
||||
service_manager.get(ServiceType.CACHE_SERVICE)
|
||||
# Setup the superuser
|
||||
initialize_database(fix_migration=fix_migration)
|
||||
try:
|
||||
initialize_database(fix_migration=fix_migration)
|
||||
except Exception as exc:
|
||||
logger.exception(exc)
|
||||
raise exc
|
||||
setup_superuser(service_manager.get(ServiceType.SETTINGS_SERVICE), next(get_session()))
|
||||
try:
|
||||
get_db_service().migrate_flows_if_auto_login()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue