forked from https://git.cyberia.club/cyberia/capsul-flask with a dockerfile from https://git.coopcloud.tech/3wordchant/capsul-flask/src/branch/master/docs/local-set-up.md just trying to arrive at a working drone config for building docker images
Go to file
forest 4a1924587c postgres automatic schema management roughly working 2020-05-09 19:13:20 -05:00
capsulflask postgres automatic schema management roughly working 2020-05-09 19:13:20 -05:00
.gitignore postgres automatic schema management roughly working 2020-05-09 19:13:20 -05:00
README.md postgres automatic schema management roughly working 2020-05-09 19:13:20 -05:00
requirements.txt postgres automatic schema management roughly working 2020-05-09 19:13:20 -05:00
setup.cfg postgres automatic schema management roughly working 2020-05-09 19:13:20 -05:00
setup.py postgres automatic schema management roughly working 2020-05-09 19:13:20 -05:00

README.md

capsulflask

Python Flask web application for capsul.org

postgres database schema management

capsulflask has a concept of a schema version. When the application starts, it will query the database for a table named schemaversion that has one row and one column (version). If the version it finds is not equal to the desiredSchemaVersion variable set in db.py, it will run migration scripts from the schema_migrations folder one by one until the schemaversion table shows the correct version.

For example, the script named 02_up_xyz.sql should contain code that migrates the database in a reverse-able fashion from schema version 1 to schema version 2. Likewise, the script 02_down_xyz.sql should contain code that migrates from schema version 2 back to schema version 1.

IMPORTANT: if you need to make changes to the schema, make a NEW schema version. DO NOT EDIT the existing schema versions.

how to run locally

Ensure you have the pre-requisites for the psycopg2 Postgres database adapter package

sudo apt-get install python3-dev libpq-dev
pg_config --version

Create python virtual environment and install packages

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Run an instance of Postgres (I used docker for this, point is its listening on localhost:5432)

docker run -it -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres

Run the app

FLASK_APP=capsulflask flask run