Skip to content

fix(dbmate-tool): default --version to all so a bare run migrates every version - #2488

Closed
breken-ai wants to merge 1 commit into
supabase:developfrom
breken-ai:fix/dbmate-tool-default-all
Closed

breken-ai wants to merge 1 commit into
supabase:developfrom
breken-ai:fix/dbmate-tool-default-all

Conversation

@breken-ai

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix (developer tooling: nix run .#dbmate-tool).

What is the current behavior?

nix/packages/dbmate-tool.nix sets the default to PSQL_VERSION="ALL", but the dispatch at the bottom checks if [ "$PSQL_VERSION" == "all" ]. A run without --version therefore skips the all-versions loop and takes the single-version path with the literal version ALL:

Migrating to PostgreSQL version ALL
nix build --no-link github:supabase/postgres#psql_ALL/bin --json   -> no such attribute, the tool exits

That breaks the documented default: --help and migrations/README.md both say --version "defaults to --version all", and the first README example is a bare nix run .#dbmate-tool. Passing --version all explicitly works, which is why CI (it always passes --version <major>) never saw this. The mismatch dates back to the tool's first version in #1316.

What is the new behavior?

The default is now all, which matches the dispatch. A bare nix run .#dbmate-tool runs every version listed in ansible/vars.yml postgres_major (15, 17, orioledb-17), as documented. Explicit --version values behave exactly as before.

Additional context

How I tested it: I don't have Nix on this machine, so I rendered the writeShellApplication text into a plain bash script and ran it with errexit/nounset/pipefail, like writeShellApplication does. I used a stub nix that logs its arguments and only knows the real psql_15/17/orioledb-17 attributes, and a stub yq that reads the real ansible/vars.yml.

  • develop, no --version: Migrating to PostgreSQL version ALL, then nix build ...#psql_ALL/bin and exit 1
  • this branch, no --version: Migrating to PostgreSQL version 15, then nix build ...#psql_15/bin (the all-versions loop)
  • this branch, --version 17: nix build ...#psql_17/bin, same as before

It is a one-line change inside the script string, so nixfmt is unaffected.

This PR was prepared by an AI agent (Claude) working for breken-ai. I reproduced the bug and checked the fix as described above, and I'm happy to change anything.

…ry version

PSQL_VERSION defaulted to "ALL" but the dispatch compares against
lowercase "all", so running the tool without --version (the documented
default and the first example in migrations/README.md) fell through to
the single-version path and tried to build the nonexistent
psql_ALL/bin flake attribute.
@breken-ai
breken-ai requested review from a team as code owners September 26, 2026 04:27
@imor

imor commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Closing as this is 100% AI generated.

@imor imor closed this Sep 27, 2026
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