Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1012 Bytes

README.md

File metadata and controls

56 lines (39 loc) · 1012 Bytes

flask-postgres

An example for project using flask and postgres stack.

Prerequisites:

  • Docker
  • Docker Compose

Development Environment

Build images,

$ docker compose build

Run containers

$ docker compose up

Visit http://127.0.0.1:5000 for development.

Attention Please

Here are some aspects that require attention, including potential tricks or pitfalls.

  • Include initdb.sql to create the database.
  • Set PGUSER=postgres to use user postgres, instead of root.
  • Set FLASK_APP to let Flask-Migrate to find the app.
  • Import models in __init__.py file so that Flask-Migrate could detect them.

Get into the container

$ docker compose exec web bash

Use the following commands to migrate your database

Init database (Already inited, you could skip this step)

$ flask db init

Migrate to create versions,

$ flask db migrate

Then upgrade new versions,

$ flask db upgrade

Happy Coding!