Skip to content

Migration tool is doing lexicographical sort on timestamp part of the migration filenames #1185

Open
@jeffreydwalter

Description

@jeffreydwalter

The migration code is doing a lexicographical sort on the timestamp part of the migration filename. That is technically incorrect and fails if one uses a non-timestamp prefix (i.e., I use ints 0_migrate.up.sql, 1_migrate.up.sql, etc.).

This is the problematic code: https://github.com/uptrace/bun/blob/master/migrate/migration.go#L292-L302

There is zero harm in changing that code to convert the value to an int64 and performing a numeric sort. Doing so works in both cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions