migrate
migrate copied to clipboard
migrate attempts to run the wrong files
Describe the Bug The migrate command will attempt to run the following files as migrations
000531_foo1.up.sql_bad
000532_foo2.up.sql~
000533_foo3.up.sql.backup
These files should be ignored by the migrate command
Steps to Reproduce Steps to reproduce the behavior:
- Create migrations with names equal to or similar to the ones listed above. The contents of the file don't matter
- Run migrations
Expected Behavior Those files should be ignored. Based on the filename, they are clearly not valid sql files for migrations.
Migrate Version
e.g. v4.16.2
Obtained by running: migrate -version
Loaded Source Drivers Source drivers: gitlab, godoc-vfs, file, bitbucket, github, github-ee, go-bindata, gcs, s3
Loaded Database Drivers Database drivers: cassandra, cockroach, cockroachdb, firebird, mongodb+srv, pgx5, mongodb, postgres, sqlserver, yugabytedb, stub, clickhouse, mysql, neo4j, pgx, postgresql, spanner, ysql, crdb-postgres, firebirdsql, pgx4, redshift, yugabyte
Go Version go version go1.21.1 darwin/arm64
Stacktrace N/A
Additional context This is particularly annoying because migrate will return a "Duplicate Migration File" error if text editors create backup files in the same directory.
This was also an issue for me. Editors often save backups next to the original files (e.g. Vim will save *.sql~ files).
There has been a rejected attempt at a PR for this: https://github.com/golang-migrate/migrate/pull/274