knex: Knex migration attempts to create already existing changelog and fails entire migration

Environment

Knex 0.14.4 PostgreSQL 9.6.6

Bug

Since the upgrade to 0.14.4 we’ve started getting this error in CI:

 Knex:warning - migration failed with error: create table "crm"."crm_migrations" ("id" serial primary key, "name" varchar(255), "batch" integer, "migration_time" timestamptz) - relation "crm_migrations" already exists
02:18:00 Error migrating:  { error: relation "crm_migrations" already exists

It looks like 7ff766f7a380dbea97b99e4d3bd2077a7b9f8f35 actually wasn’t as innocent as expected. Might be related to the fact that we are using custom migration changelog table via

tableName: ${SCHEMA}.crm_migrations

parameter.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

Hi @elhigu. Sorry, I meant no harm. But adding this feature as a patch and then force developers to change the use of the lib doesn’t quite follows semver (it actually sounds like a BC). In a way, doing it on a patch have broken the use of it for everyone that allows patch updates.

Just a heads-up: I’ve finally started working on it, hopefully will be able to produce something working soon.

Exactly, after this update came out, our CI builds started failing without us changing anything, and that is pretty much a definition of semver breaking change. I’ll look into providing a PR for this next week.