Commit e5a72688 authored by Hugo Kerstens's avatar Hugo Kerstens

Add instructions for generating migrations to README

parent f0e6624b
......@@ -71,6 +71,18 @@ try the instructions listed
[here]( as
a first resort.
### Database modifications
Zesje uses Flask-Migrate and Alembic for database versioning and migration. Flask-Migrate is an extension that handles SQLAlchemy database migrations for Flask applications using Alembic.
To change something in the database schema, simply add this change to `zesje/`. After that run the following command to prepare a new migration:
yarn prepare-migration
This uses Flask-Migrate to make a new migration script in `migrations/versions` which needs to be reviewed and edited. Please suffix the name of this file with something distinctive and add a short description at the top of the file. To apply the database migration run:
yarn migrate:dev # (for the development database)
yarn migrate # (for the production database)
### Building and running the production version
......@@ -15,7 +15,8 @@
"start": "ZESJE_SETTINGS=$(pwd)/ python3 zesje",
"analyze": "webpack --config --profile --json > stats.json; webpack-bundle-analyzer stats.json zesje/static",
"migrate:dev": "ZESJE_SETTINGS=$(pwd)/ FLASK_APP=zesje/ flask db upgrade",
"migrate": "FLASK_APP=zesje/ flask db upgrade"
"migrate": "FLASK_APP=zesje/ flask db upgrade",
"prepare-migration": "ZESJE_SETTINGS=$(pwd)/ FLASK_APP=zesje/ flask db migrate"
"standard": {
"parser": "babel-eslint",
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment