mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-14 13:40:54 +00:00
refactor: Refactor storage system (#937)
This commit is contained in:
@@ -3,7 +3,7 @@ from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
|
||||
from dbgpt.storage.metadata.meta_data import Base, engine
|
||||
from dbgpt.storage.metadata.db_manager import db
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
@@ -13,8 +13,7 @@ config = context.config
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
target_metadata = Base.metadata
|
||||
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
@@ -34,6 +33,8 @@ def run_migrations_offline() -> None:
|
||||
script output.
|
||||
|
||||
"""
|
||||
engine = db.engine
|
||||
target_metadata = db.metadata
|
||||
url = config.get_main_option(engine.url)
|
||||
context.configure(
|
||||
url=url,
|
||||
@@ -53,12 +54,8 @@ def run_migrations_online() -> None:
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
connectable = engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
|
||||
engine = db.engine
|
||||
target_metadata = db.metadata
|
||||
with engine.connect() as connection:
|
||||
if engine.dialect.name == "sqlite":
|
||||
context.configure(
|
||||
|
Reference in New Issue
Block a user