migrate icon indicating copy to clipboard operation
migrate copied to clipboard

migrate attempts to run the wrong files

Open whunt-smithrx opened this issue 1 year ago • 1 comments

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:

  1. Create migrations with names equal to or similar to the ones listed above. The contents of the file don't matter
  2. 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.

whunt-smithrx avatar Nov 02 '23 22:11 whunt-smithrx

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

simlmx avatar Jan 27 '24 15:01 simlmx