erikbra / grate

grate - the SQL scripts migration runner
MIT License
209 stars 40 forks source link

Running grate on a postgres database which had previously been migrated using roundhouse does not work. #3 #597

Open cocytus opened 1 week ago

cocytus commented 1 week ago

Reproducing bug:

Run RH on Postgres DB (on Windows). Works. Tables created.

Run Grate on same DB using correct --schema. Grate renames/recreates the scriptsrun table to ScriptsRun. No errors because of no schema changes.

Create a new sql script for grate to run in up folder. Error:

Update ("up"):
--------------------------------------------------------------------------------
0053_TheScript.sql: 23505: duplicate key value violates unique constraint "roundhouse_scriptsrun_pk"
(0,0): UPDATE "MyTable"
      ^ 23505: duplicate key value violates unique constraint "roundhouse_scriptsrun_pk"
Exception: Database migration (Update) failed!, exiting.. 1

Reason: ScriptsRun id column has SELECT nextval('roundhouse.scriptsrun_id_seq'::regclass) default value. This value is not set to the correct MAX(id)+1 after the RH->Grate migration.