修复映射数据库表失败问题

This commit is contained in:
ktianc 2023-08-25 17:11:58 +08:00
parent ee4f4612fe
commit 1ee46b24f7

View File

@ -8,7 +8,7 @@ from alembic import context
import os import os
import sys import sys
from core.database import Model from core.database import Base
# this is the Alembic Config object, which provides # this is the Alembic Config object, which provides
# access to the values within the .ini file in use. # 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.auth.models import *
from apps.vadmin.system.models import * from apps.vadmin.system.models import *
from apps.vadmin.record.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(): 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") url = config.get_main_option("sqlalchemy.url")
context.configure( context.configure(
@ -69,11 +63,8 @@ def run_migrations_offline():
def run_migrations_online(): 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( connectable = engine_from_config(
config.get_section(config.config_ini_section), config.get_section(config.config_ini_section),
@ -91,6 +82,8 @@ def run_migrations_online():
if context.is_offline_mode(): if context.is_offline_mode():
print("offline")
run_migrations_offline() run_migrations_offline()
else: else:
print("online")
run_migrations_online() run_migrations_online()