alembic支持检测字段长度改变,不过它不是默认的,需要配置;
找到migrations/env.py文件,在run_migrations_online函数加入如下内容:

context.configure(
    …………
    compare_type=True,  # 检查字段类型
    compare_server_default=True # 比较默认值
)

重新运行以下命令便可生效

python manage.py db migrate
python manage.py db upgrade
Last modification:June 6, 2022
If you think my article is useful to you, please feel free to appreciate