mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
refac
This commit is contained in:
parent
d8d2f3529f
commit
673b893a8a
@ -55,17 +55,15 @@ else:
|
|||||||
# This is required to ensure the peewee migration is handled before the alembic migration
|
# This is required to ensure the peewee migration is handled before the alembic migration
|
||||||
def handle_peewee_migration(DATABASE_URL):
|
def handle_peewee_migration(DATABASE_URL):
|
||||||
try:
|
try:
|
||||||
# Replace the postgresql:// with postgres:// and %40 with @ in the DATABASE_URL
|
# Replace the postgresql:// with postgres:// to handle the peewee migration
|
||||||
db = register_connection(
|
db = register_connection(
|
||||||
DATABASE_URL.replace("postgresql://", "postgres://").replace("%40", "@")
|
DATABASE_URL.replace("postgresql://", "postgres://"), unquote_password=True
|
||||||
)
|
)
|
||||||
migrate_dir = BACKEND_DIR / "apps" / "webui" / "internal" / "migrations"
|
migrate_dir = BACKEND_DIR / "apps" / "webui" / "internal" / "migrations"
|
||||||
router = Router(db, logger=log, migrate_dir=migrate_dir)
|
router = Router(db, logger=log, migrate_dir=migrate_dir)
|
||||||
router.run()
|
router.run()
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
# check if db connection has been closed
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(f"Failed to initialize the database connection: {e}")
|
log.error(f"Failed to initialize the database connection: {e}")
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user