Skip to content

fix(cli): treat migration creation directories as literal paths - #1453

Open
sergioperezcheco wants to merge 1 commit into
golang-migrate:masterfrom
sergioperezcheco:fix/create-literal-directory-20261005
Open

sergioperezcheco wants to merge 1 commit into
golang-migrate:masterfrom
sergioperezcheco:fix/create-literal-directory-20261005

Conversation

@sergioperezcheco

Copy link
Copy Markdown

create -dir treats the directory as a literal path when creating files, but currently passes it unescaped to filepath.Glob. In a directory such as migrations[dev], sequential creation can reuse version 000001 or pick up a similarly named sibling's version; an unmatched [ causes a pattern syntax error. Timestamp creation can also miss an existing version in the requested directory.

Escape only the directory portion of both glob patterns, retaining the existing filename matching and version-selection behavior. Regression tests cover sequential creation, unrelated sibling directories, timestamp duplicate rejection, and ordinary paths, with platform-specific handling for literal backslashes and invalid Windows filenames.

Verified the unchanged-production failures and fixed behavior through both package tests and the built CLI. CLI and core/file/iofs/httpfs/stub race tests, CLI vet, and incremental lint passed locally on macOS with Go 1.26.4 and golangci-lint 2.13.1. The complete Docker database matrix, Windows/Linux execution, and CI-pinned lint 2.11.4 were not run locally.

From Hermes Agent / gpt-6.1-sol.

Signed-off-by: sergioperezcheco <checo520@outlook.com>
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 54.971%. first build — sergioperezcheco:fix/create-literal-directory-20261005 into golang-migrate:master

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.

2 participants