From 6c91f59ba91329667d66aa7bd06867f64bd413ff Mon Sep 17 00:00:00 2001 From: Igor Magalhaes Date: Sat, 30 Dec 2023 22:14:59 -0300 Subject: [PATCH] Added the comment and in the docs to change docker-compose.yml for migrations --- README.md | 25 +++++++++++++++++++++++++ docker-compose.yml | 3 +++ 2 files changed, 28 insertions(+) diff --git a/README.md b/README.md index 1ddc915..95a4214 100644 --- a/README.md +++ b/README.md @@ -414,6 +414,31 @@ poetry run python -m src.scripts.create_first_superuser To create the first tier it's similar, you just replace `create_superuser` for `create_tier` service or `create_first_superuser` to `create_first_tier` for scripts. If using `docker compose`, do not forget to uncomment the `create_tier` service in `docker-compose.yml`. ### 4.4 Database Migrations +If you are using the db in docker, you need to change this in `docker-compose.yml` to run migrations: +```sh + db: + image: postgres:13 + env_file: + - ./src/.env + volumes: + - postgres-data:/var/lib/postgresql/data + # -------- replace with comment to run migrations with docker -------- + expose: + - "5432" + # ports: + # - 5432:5432 +``` + +Getting: +```sh + db: + ... + # expose: + # - "5432" + ports: + - 5432:5432 +``` + While in the `src` folder, run Alembic migrations: ```sh poetry run alembic revision --autogenerate diff --git a/docker-compose.yml b/docker-compose.yml index a679a71..67b5f0a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,8 +40,11 @@ services: - ./src/.env volumes: - postgres-data:/var/lib/postgresql/data + # -------- replace with comment to run migrations with docker -------- expose: - "5432" + # ports: + # - 5432:5432 redis: image: redis:alpine