From 1ee46b24f77975ac807600e2e393027ba9db02fa Mon Sep 17 00:00:00 2001 From: ktianc Date: Fri, 25 Aug 2023 17:11:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=98=A0=E5=B0=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=A1=A8=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kinit-api/alembic/env.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/kinit-api/alembic/env.py b/kinit-api/alembic/env.py index 9e18fc8..b5dca67 100644 --- a/kinit-api/alembic/env.py +++ b/kinit-api/alembic/env.py @@ -8,7 +8,7 @@ from alembic import context import os import sys -from core.database import Model +from core.database import Base # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -37,22 +37,16 @@ sys.path.append(BASE_DIR) from apps.vadmin.auth.models import * from apps.vadmin.system.models import * from apps.vadmin.record.models import * +from apps.vadmin.help.models import * +from apps.vadmin.resource.models import * # 修改配置中的参数 -target_metadata = Model.metadata +target_metadata = Base.metadata def run_migrations_offline(): - """Run migrations in 'offline' mode. - - This configures the context with just a URL - and not an Engine, though an Engine is acceptable - here as well. By skipping the Engine creation - we don't even need a DBAPI to be available. - - Calls to context.execute() here emit the given string to the - script output. - + """ + 以“脱机”模式运行迁移。 """ url = config.get_main_option("sqlalchemy.url") context.configure( @@ -69,11 +63,8 @@ def run_migrations_offline(): def run_migrations_online(): - """Run migrations in 'online' mode. - - In this scenario we need to create an Engine - and associate a connection with the context. - + """ + 以“在线”模式运行迁移。 """ connectable = engine_from_config( config.get_section(config.config_ini_section), @@ -91,6 +82,8 @@ def run_migrations_online(): if context.is_offline_mode(): + print("offline") run_migrations_offline() else: + print("online") run_migrations_online()