From 3b5f94f639357ca602eeb03431683dd5f219c4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADsa=20Moura?= Date: Thu, 6 Jun 2024 21:08:17 -0400 Subject: [PATCH] Docs: add alembic troubleshooting (#181) * Docs: add alembic troubleshooting * comments --- .github/workflows/check_revision_id.yml | 4 ++-- docs/troubleshooting.md | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_revision_id.yml b/.github/workflows/check_revision_id.yml index ba5b197ebf..1f03211273 100644 --- a/.github/workflows/check_revision_id.yml +++ b/.github/workflows/check_revision_id.yml @@ -3,10 +3,10 @@ name: Check for duplicate revision IDs on: pull_request: paths: - - 'src/backend/alembic/versions/' + - 'src/backend/alembic/versions/**' push: paths: - - 'src/backend/alembic/versions/' + - 'src/backend/alembic/versions/**' jobs: check-alembic-revision-ids: diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index d3c655c9d9..9d1b58b7ef 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -50,3 +50,18 @@ import pdb; pdb.set_trace() it will allow you to debug. + +## Alembic migrations out of sync error: + +When developing on the backend if database model changes are made in different git branches your Alembic migrations may diverge. + +If you have changes on your branch_a that contains a migration .py that is out of sync with the main branch, first downgrade your local branch using: + +docker compose run --build backend alembic -c src/backend/alembic.ini downgrade -1 +Then delete .py for your existing changes, and run: + +make migrate +To sync with main, then: + +make migration +to regenerate your migrations. \ No newline at end of file