[英]Detect changes to models.py using Alembic with Flask-SQLAlchemy in Flask Application
I'm trying to use Alembic with Flask-SQLAlchemy and Flask. 我正在尝试将Alembic与Flask-SQLAlchemy和Flask一起使用。 Here is my application directory structure
这是我的应用程序目录结构
/myapp
app.py
/module1
__init__.py
views.py
/module2
__init__.py
models.py
alembic.ini
/migrations
env.py
I have a couple of classes in models.py. 我在models.py中有几个类。 What I want is a method such that alembic can check for the changes (like any new added classes in models.py) and generate a version file (upon running a command) so that it reflects in the upgrade() function.
我想要的是一种方法,使得alembic可以检查更改(如models.py中的任何新添加的类)并生成版本文件(运行命令时),以便它反映在upgrade()函数中。
How do i achieve this?. 我如何实现这一目标? I am sure this should be possible but not getting how to accomplish this!
我相信这应该是可能的,但没有得到如何实现这一目标!
PS: If you need any extra information please let me know. PS:如果您需要任何额外信息,请告诉我。
alembic revision --autogenerate -m "<message_here>"
and 和
alembic upgrade head
are the commands that i needed! 是我需要的命令!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.