refactor: Refactor storage system (#937)

This commit is contained in:
Fangyin Cheng
2023-12-15 16:35:45 +08:00
committed by GitHub
parent a1e415d68d
commit aed1c3fb2b
55 changed files with 3780 additions and 680 deletions

View File

@@ -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(