Create .env file in root directory :
ENV=development
PROJECT_NAME=FastAPI Skeleton
APP_VERSION=1.0.0
DATABASE_USER=app
DATABASE_PASSWORD=password
DATABASE_URL=127.0.0.1
DATABASE_NAME=skeleton
DATABASE_PORT=5432
Use at least python 3.10.
python3 -m venv venv
source venv/bin/activatepip3 install -r requirements/dev.txt # or prod.txtInstall PostgreSQL here.
And then create a database/user :
CREATE DATABASE app
CREATE USER app WITH PASSWORD 'password';If there is no versions in migrations/versions folder, execute this command :
# Generate version file
alembic revision --autogenerate -m "init"To apply your migration file to the database :
alembic upgrade headIn case of error : FAILED: Can't locate revision identified by '747e6da84866' you might delete entry in alembic_version table :
$ docker exec -it postgres-app psql -U app
DELETE FROM alembic_version;python3 main.py