Skip to content

go-migrate implementation broken #1266

Closed
@senekor

Description

@senekor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions