Flask by Example – Part 2 – Postgres, SQLAlchemy, and Alembic
realpython.com
realpython.com
1. deploy new code to prod
2. run migration on prod via a one-off dyno instance
However, in step 1 you are pushing code that relies on new tables/fields that don't yet exist, causing errors and likely downtime for the app.
To avoid this, you can instead have Alembic generate SQL from the migration and then apply that SQL to the prod DB directly prior to deploying the updated code.
It may be beneficial to update the post to specify the initial setup vs. migrations after the production env is setup. Or we could just add that in the next post.
Thanks!
In any case, good job on a well written set of posts.
I've recently started getting into Python and love Flask so far (spares newbies from having to buy into bullshit philosophies which are irrelevant to me). Would love to understand better what this project is trying to accomplish
2. Context: We're going to build an app using Flask with a simple text box that you enter text into and the app processes and displays a count of how many times each word appears on the page.
3. Parts:
In part one, we'll set up a local development environment and then deploy both a staging environment and a production environment on Heroku.
In part two, we'll set up our PostgreSQL database along with SQLAlchemy as our ORM and Alembic to handle migrations.
In part three, we'll be doing a bunch of backend processing to count the words of a web page so we’ll implement a request queue that will do the actual processing of the words. (coming soon!)
Does that answer your questions? Best!