Starting Alembic migration to Google App Engine

I have a Flask application that uses SQLAlchemy (Flask-SQLAlchemy) and Alembic (Flask-Migrate). The application 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, how do I migrate to it?

+5
source share
3 answers
+2
source

You can use the white IP address of your local computer for the Google Cloud SQL instance, then run the script on your local machine.

+1
source

This is just code that you can run, so you can create an admin endpoint from which you can upgrade:

 @app.route('/admin/dbupgrade') def dbupgrade(): from flask_migrate import upgrade, Migrate migrate = Migrate(app, db) upgrade(directory=migrate.directory) return 'migrated' 

(Dropwizard, for example, is great for admin stuff like this through tasks )

0
source

Source: https://habr.com/ru/post/1242977/


All Articles