Description
Description
When running dbmate up
the migration table is not found thus migrations in the migration directory are re-ran every single time which result in an error.
We currently run dbmate part of a shell script that loops over some values and applies the migrations for each value in the loop.
It looks something like the following:
values=$(cat cars)
for value in $values; do
echo "Migrating up '$value' schema"
dbmate \
--url "$DATABASE_URL" \
--migrations-dir "migrations/$value" \
--migrations-table "$value.schema_migrations" \
--no-dump-schema \
--wait \
up
done
The DATABASE_URL
has the following value: postgresql://atlas:postgres@localhost:5432/atlas?sslmode=disable
When using dbmate version 1.6.0, everything works as expected. When we updated to version 2.X.X, we started seeing the previously described behavior.
By running dbmate in my IDE and setting breakpoints, I was able to trace where the issue is. For Postgres, in the quotedMigrationsTableNameParts
method, the quote_ident
function that's being used to add quotations around the schema name are resulting in the table schema_migrations
not to be found even though it exists. If the query used to find the schema migration tables is adjusted from select quote_ident(unnest($1::text[]))
to select unnest($1::text[])
then the schema migrations is correctly found.
This behavior seems to not exist in version 1.6.0
- Version: 2
- Database: Postgres 12 running inside a docker container
- Operating System: macOS
Steps To Reproduce
dbmate
--url "postgresql://atlas:postgres@localhost:5432/atlas?sslmode=disable"
--migrations-dir "migrations/bmw"
--migrations-table "bmw.schema_migrations"
--no-dump-schema
--wait
up
the migrations in the migration directory are always ran as if it's the first time dbmate is running
Expected Behavior
the migrations that already ran and are in the schema_migrations
table are not ran and only new migrations run