🐛 fix(utils.py): handle exception when creating DB and tables to ignore if tables already exist
🐛 fix(utils.py): handle exception when running migrations to ignore if migrations already ran ✨ feat(auth.py): set AUTO_LOGIN to True to enable automatic login as a super user
This commit is contained in:
parent
765db810c7
commit
0ea1c087ee
2 changed files with 12 additions and 3 deletions
|
|
@ -13,7 +13,17 @@ def initialize_database():
|
||||||
logger.debug("Initializing database")
|
logger.debug("Initializing database")
|
||||||
from langflow.services import service_manager, ServiceType
|
from langflow.services import service_manager, ServiceType
|
||||||
|
|
||||||
database_service = service_manager.get(ServiceType.DATABASE_SERVICE)
|
database_service: "DatabaseService" = service_manager.get(
|
||||||
|
ServiceType.DATABASE_SERVICE
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
database_service.create_db_and_tables()
|
||||||
|
except Exception as exc:
|
||||||
|
# if the exception involves tables already existing
|
||||||
|
# we can ignore it
|
||||||
|
if "already exists" not in str(exc):
|
||||||
|
logger.error(f"Error creating DB and tables: {exc}")
|
||||||
|
raise RuntimeError("Error creating DB and tables") from exc
|
||||||
try:
|
try:
|
||||||
database_service.check_schema_health()
|
database_service.check_schema_health()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|
@ -39,7 +49,6 @@ def initialize_database():
|
||||||
if "already exists" not in str(exc):
|
if "already exists" not in str(exc):
|
||||||
logger.error(f"Error running migrations: {exc}")
|
logger.error(f"Error running migrations: {exc}")
|
||||||
raise RuntimeError("Error running migrations") from exc
|
raise RuntimeError("Error running migrations") from exc
|
||||||
database_service.create_db_and_tables()
|
|
||||||
logger.debug("Database initialized")
|
logger.debug("Database initialized")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class AuthSettings(BaseSettings):
|
||||||
|
|
||||||
# If AUTO_LOGIN = True
|
# If AUTO_LOGIN = True
|
||||||
# > The application does not request login and logs in automatically as a super user.
|
# > The application does not request login and logs in automatically as a super user.
|
||||||
AUTO_LOGIN: bool = False
|
AUTO_LOGIN: bool = True
|
||||||
NEW_USER_IS_ACTIVE: bool = False
|
NEW_USER_IS_ACTIVE: bool = False
|
||||||
SUPERUSER: str = DEFAULT_SUPERUSER
|
SUPERUSER: str = DEFAULT_SUPERUSER
|
||||||
SUPERUSER_PASSWORD: str = DEFAULT_SUPERUSER_PASSWORD
|
SUPERUSER_PASSWORD: str = DEFAULT_SUPERUSER_PASSWORD
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue