Open iliapisaniy opened 2 years ago
And version_id is not unique
To confirm, are you using -allow-missing
flag to apply out-of-order migrations? If so, I believe this is what you are running into:
https://github.com/pressly/goose/pull/280#issuecomment-945006038
I've created an issue to address the Status
command. https://github.com/pressly/goose/issues/282
Correct, version_id
is not enforced as unique in the database (it probably should be, but difficult to change now), however, goose
will report an error and fail if it detects a duplicate version files so in theory this should never happen.
goose: duplicate version N detected:
data/schema/migrations/000N_migration.sql
data/schema/migrations/000N_yet_another_migraiton.sql
No, we aren't use -allow-missing
flag.
It is possible to ORDER BY version_id, id DESC
and think it is solution of the problem
@mfridman
To determine the current version of the database, goose sorts migrations in the goose_db_version table by ID (get biggest). The status command sorts migrations by version_id (as the beginning of the file name).
To get the current migration version, goose must order the `goose_db_version' rows by version id. In our case of parallel releases, some migrations with a larger version_id have a smaller primary key ID. Thus, the detection of the current version does not work correctly
goose version: up to 3.5.3 db: postgresql