alembic 迁移数据库加入支持检查字段类型,字段长度,数据库字段默认值
This commit is contained in:
parent
66806dac91
commit
08c681e608
@ -54,8 +54,8 @@ def run_migrations_offline():
|
|||||||
target_metadata=target_metadata,
|
target_metadata=target_metadata,
|
||||||
literal_binds=True,
|
literal_binds=True,
|
||||||
dialect_opts={"paramstyle": "named"},
|
dialect_opts={"paramstyle": "named"},
|
||||||
compare_type=True, # 检查字段类型
|
compare_type=True, # 是否检查字段类型,字段长度
|
||||||
compare_server_default=True # 比较默认值
|
compare_server_default=True # 是否比较在数据库中的默认值
|
||||||
)
|
)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
@ -74,7 +74,10 @@ def run_migrations_online():
|
|||||||
|
|
||||||
with connectable.connect() as connection:
|
with connectable.connect() as connection:
|
||||||
context.configure(
|
context.configure(
|
||||||
connection=connection, target_metadata=target_metadata
|
connection=connection,
|
||||||
|
target_metadata=target_metadata,
|
||||||
|
compare_type=True, # 是否检查字段类型,字段长度
|
||||||
|
compare_server_default=True # 是否比较在数据库中的默认值
|
||||||
)
|
)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user