在Google App Engine上运行Alembic迁移 [英] Run Alembic migrations on Google App Engine
问题描述
在我的机器上运行 python manage.py db upgrade
来运行我的本地数据库迁移。由于GAE不允许运行任何shell命令,我如何在其上运行迁移?
SQLALCHEMY_DATABASE_URI ='mysql:// user:pw @ ip:3306 / DBNAME'
I have a Flask app that uses SQLAlchemy (Flask-SQLAlchemy) and Alembic (Flask-Migrate). The app runs on Google App Engine. I want to use Google Cloud SQL.
On my machine, I run python manage.py db upgrade
to run my migrations against my local database. Since GAE does not allow arbitrary shell commands to be run, how do I run the migrations on it?
- Whitelist your local machine's IP: https://console.cloud.google.com/sql/instances/INSTANCENAME/access-control/authorization?project=PROJECTNAME
- Create an user: https://console.cloud.google.com/sql/instances/INSTANCENAME/access-control/users?project=PROJECTNAME
- Assign an external IP address to the instance: https://console.cloud.google.com/sql/instances/INSTANCENAME/access-control/ip?project=PROJECTNAME
- Use the following SQLAlchemy connection URI:
SQLALCHEMY_DATABASE_URI = 'mysql://user:pw@ip:3306/DBNAME'
- Remember to release the IP later as you are charged for every hour it's not used
这篇关于在Google App Engine上运行Alembic迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!