Closed
Description
Version
1.10.0
What happened?
go-migrate files are executed in the wrong order. file 10_foo.up.sql
is executed before 9_bar.up.sql
. go-migrate specifies that the files are to be executed in order of the version number, not alphabetically.
https://github.com/golang-migrate/migrate/blob/v3.5.4/MIGRATIONS.md
The issue seems to be in internal/sql/sqlpath/read.go
, where the migration files are read from the file system in alphabetical order without parsing the go-migrate version number at all.
I suggest sorting the files according to the go-migrate version number before executing them. Alternatively, one could adjust the documentation to clearly state this limitation.
Relevant log output
No response
Database schema
No response
SQL queries
No response
Configuration
No response
Playground URL
No response
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go