Skip to content

FIX: Re-Enable Auto-Migration for Dev#69

Open
zdomke wants to merge 1 commit intomainfrom
zdomke/auto-migrate-fix
Open

FIX: Re-Enable Auto-Migration for Dev#69
zdomke wants to merge 1 commit intomainfrom
zdomke/auto-migrate-fix

Conversation

@zdomke
Copy link
Copy Markdown
Contributor

@zdomke zdomke commented Mar 31, 2026

Description

Previously disabled auto-migration in a hotfix (#68). I realized that setting a common entrypoint for all containers to migrate the database, as I did in #56, caused a race condition where multiple containers were trying to run the migration at the same time. This caused squirrel-api to crash on my end.

This PR will only run the migration if the RUN_MIGRATIONS environment variable is set to "true". If it is set to something else or is missing then the migrations will not run. This is entrypoint should only be used for dev environments and we may want a separate entrypoint for prod.

Motivation

Auto migrating the database was nice while it lasted. I wanted it back after #68.

Pre-merge checklist

  • Code works interactively
  • Code contains descriptive docstrings
  • New/changed functions and methods are covered in the test suite where possible
  • Test suite passes locally
  • Test suite passes on GitHub Actions

@zdomke zdomke self-assigned this Mar 31, 2026
@zdomke zdomke added the bug Something isn't working label Mar 31, 2026
@zdomke
Copy link
Copy Markdown
Contributor Author

zdomke commented Mar 31, 2026

In it's current state, the entrypoint does not try to handle the case of multiple alembic heads.
I may use alembic upgrade heads which will upgrade using all branches. Not sure if this behavior is desirable opposed to making sure we use just one branch/head.

@zdomke zdomke changed the title FIX: Reenable Auto-Mmigration for Dev FIX: Re-Enable Auto-Migration for Dev Mar 31, 2026
@zdomke zdomke requested a review from a team March 31, 2026 21:29
@zdomke zdomke marked this pull request as ready for review March 31, 2026 21:29
@zdomke
Copy link
Copy Markdown
Contributor Author

zdomke commented Mar 31, 2026

In it's current state, the entrypoint does not try to handle the case of multiple alembic heads. I may use alembic upgrade heads which will upgrade using all branches. Not sure if this behavior is desirable opposed to making sure we use just one branch/head.

Decided against this as the main branch should probably only ever have one alembic branch. If it does have diverging branches, we should know more about why and how to handle it then.

For now, if there are multiple heads they should be merged using alembic merge heads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant