Skip to content

feat(configuration): accept a version string in migrations.after - #1145

Open
psteinroe wants to merge 4 commits into
fix/goose-envsub-string-typecheckfrom
feat/migrations-after-string
Open

psteinroe wants to merge 4 commits into
fix/goose-envsub-string-typecheckfrom
feat/migrations-after-string

Conversation

@psteinroe

@psteinroe psteinroe commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #1103.

migrations.after was a u64, so it only worked for migration tools whose versions are plain numbers, and a value that matched no file name ignored nothing without saying so. Since #993, each migration tool reads the version of its migration files itself (MigrationTool::version), so after can be read the same way:

{ "migrations": { "migrationsDir": "migrations", "after": "0042" } }   // same as 42

What changed

  • migrations.after is a MigrationVersion: a number or a string (#[serde(untagged)]), integer | string in schema.json. --after takes a VERSION; digits are read as a number. Existing configurations keep working.
  • after and the version of each migration file are both read with the selected tool's version(), and a file is ignored when its version is at most after. All current tools read <number>_<name>.sql with leading zeros stripped, so "0042" and 42 are the same, as before.
  • A value that isn't a version of the tool, like "v1", ignores nothing, as before, but now the CLI prints a warning and the editor shows one: "migrations.after is v1, which is not a version of goose migrations, so no migration is ignored. …". It's a new ConfigurationNotice::InvalidSettings, next to the deprecation notices. 0, the default, isn't reported.
  • The tool of migrations.tool is looked up in one place now (settings::migration_tool).
  • The migrations guide explains the format; just gen-lint regenerated schema.json, the TS bindings and the CLI reference.

Tests

  • pgls_configuration: after_is_a_number_or_a_string (number, string, FromStr with leading zeros and text, negative numbers rejected).
  • pgls_workspace: migrations_after_is_a_number_or_a_string (number and string, leading zeros in after and in file names, an invalid value ignoring nothing), reports_an_after_that_is_not_a_version_of_the_tool.
  • nested_configurations_have_their_own_migrations_settings and the CLI --after tests are unchanged.

Not covered

  • --after given on the command line isn't checked for the warning, only after in a configuration file.
  • All tools still read numeric versions. Dotted (Flyway) or name-based (Sqitch) versions come with those tools.

Update: --after is checked too now. The configuration notices are about the file, so the CLI checks the configuration as applied when --after is given, with the tool of the file or of --migration-tool, and prints the same warning (after_argument_that_is_no_version_is_reported). The first "Not covered" item is done.

`after` was a u64, so only tools whose versions are plain numbers could use it.
It now takes a number or a string (`MigrationVersion`), and both `after` and
the version of each migration file are read with the selected tool's
`version()`. A value that isn't a version of the tool ignores nothing, and the
CLI and the editor show a warning (`ConfigurationNotice::InvalidSettings`).
@psteinroe
psteinroe added this pull request to stack #1092 November 9, 2026 08:20

This branch has not been deployed

No deployments
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.

1 participant