Skip to content

DEV: Docker Entrypoint for Alembic Upgrade#56

Merged
zdomke merged 1 commit intomainfrom
zdomke/docker-entrypoint
Mar 30, 2026
Merged

DEV: Docker Entrypoint for Alembic Upgrade#56
zdomke merged 1 commit intomainfrom
zdomke/docker-entrypoint

Conversation

@zdomke
Copy link
Copy Markdown
Contributor

@zdomke zdomke commented Mar 27, 2026

Description

Add an entrypoint to Dockerfile.dev to run alembic upgrade head automatically before when starting docker containers. We may only want to upgrade automatically for dev environments, so we may choose to avoid this if we have a separate prod docker file.

One of the benefits to using alembic here is that if alembic's current iteration is already on the head, then nothing happens.

Motivation

We were tired of running alembic upgrade head when removing/building volumes. Even more tired of forgetting to run that command.

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 requested a review from a team March 27, 2026 20:36
@zdomke zdomke self-assigned this Mar 27, 2026
@zdomke zdomke changed the title MNT: Docker Entrypoint for Alembic Upgrade DEV: Docker Entrypoint for Alembic Upgrade Mar 27, 2026
@zdomke zdomke force-pushed the zdomke/docker-entrypoint branch from 681091f to efd7dba Compare March 30, 2026 18:44
Copy link
Copy Markdown
Contributor

@shilorigins shilorigins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me, thanks!

@shilorigins
Copy link
Copy Markdown
Contributor

Can you also remove the alembic upgrade head command from the installation docs in this PR?

@zdomke
Copy link
Copy Markdown
Contributor Author

zdomke commented Mar 30, 2026

Can you also remove the alembic upgrade head command from the installation docs in this PR?

So I looked through all of the documentation for any references to alembic upgrade head and I'm mostly only seeing it come up in a couple of scenarios:

  1. As a reference for alembic commands that may be useful to developers (such as migrations.md)
  2. In reference to the "Local Development" installation

I think these both have their problems, but the way they use the command is kinda correct.

We should consider a documentation overhaul (#34) at some point because there's a lot of bad documentation in here. For example, we probably don't need a quick reference for the Alembic commands in our docs. We could possibly link to existing Alembic documentation instead. And as for the "Local Development", the docs consistently reference a script that doesn't exist called seed_pvs.

TL;DR: I think I'm going to leave the docs references to alembic upgrade head because I can't find any that are made incorrect by this PR.

@zdomke zdomke force-pushed the zdomke/docker-entrypoint branch from efd7dba to 122cebe Compare March 30, 2026 23:42
@zdomke zdomke merged commit 5d8f864 into main Mar 30, 2026
2 checks passed
@zdomke zdomke deleted the zdomke/docker-entrypoint branch March 30, 2026 23:45
@shilorigins
Copy link
Copy Markdown
Contributor

@zdomke A wrinkle for automatic updates? I'm getting this error in squirrel-api when trying to run off of a dev branch:

squirrel-api  | INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
squirrel-api  | INFO  [alembic.runtime.migration] Will assume transactional DDL.
squirrel-api  | ERROR [alembic.util.messaging] Multiple head revisions are present for given argument 'head'; please specify a specific target revision, '<branchname>@head' to narrow to a specific head, or 'heads' for all heads
squirrel-api  | FAILED: Multiple head revisions are present for given argument 'head'; please specify a specific target revision, '<branchname>@head' to narrow to a specific head, or 'heads' for all heads

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants