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)
|
command.check(alembic_cfg)
|
||||||
except util.exc.AutogenerateDiffsDetected as exc:
|
except util.exc.AutogenerateDiffsDetected as exc:
|
||||||
logger.exception("AutogenerateDiffsDetected: {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:
|
if fix:
|
||||||
self.try_downgrade_upgrade_until_success(alembic_cfg)
|
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
|
# if the exception involves tables already existing
|
||||||
# we can ignore it
|
# we can ignore it
|
||||||
if "already exists" not in str(exc):
|
if "already exists" not in str(exc):
|
||||||
logger.error(f"Error running migrations: {exc}")
|
logger.error(exc)
|
||||||
raise RuntimeError("Error running migrations") from exc
|
|
||||||
|
raise exc
|
||||||
logger.debug("Database initialized")
|
logger.debug("Database initialized")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,11 @@ def initialize_services(fix_migration: bool = False):
|
||||||
# Test cache connection
|
# Test cache connection
|
||||||
service_manager.get(ServiceType.CACHE_SERVICE)
|
service_manager.get(ServiceType.CACHE_SERVICE)
|
||||||
# Setup the superuser
|
# 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()))
|
setup_superuser(service_manager.get(ServiceType.SETTINGS_SERVICE), next(get_session()))
|
||||||
try:
|
try:
|
||||||
get_db_service().migrate_flows_if_auto_login()
|
get_db_service().migrate_flows_if_auto_login()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue