graphile/migrate

Message header lost on commit error

PizzaPartyInc opened this issue ยท 5 comments

Summary

When you try to commit a migration which has a --! Message: header in current.sql, and that migration fails for some reason, e.g. syntax error, current.sql is restored, but the --! Message: is lost.

Steps to reproduce

Have contents of current.sql as such:

--! Message: test-migration

DROP TABLE IF EXISTS app_public.table_name CASCADE;
CREATE TABLE app_public.table_name(
  id TEXT PRIMARY KEY,
  title TEXT, --this comma causes an error
);

run the commit command and get an error like this:
image

Expected results

Have contents of current.sql the same as before failure:

--! Message: test-migration

DROP TABLE IF EXISTS app_public.table_name CASCADE;
CREATE TABLE app_public.table_name(
  id TEXT PRIMARY KEY,
  title TEXT, --this comma causes an error
);

Actual results

Actual contents of current.sql are missing the header:

DROP TABLE IF EXISTS app_public.table_name CASCADE;
CREATE TABLE app_public.table_name(
  id TEXT PRIMARY KEY,
  title TEXT, --this comma causes an error
);

Additional context

graphile-migrate version 1.0.2.

Possible Solution

Since there is a log before that like

graphile-migrate[shadow]: Running migration '000002-test-migration.sql'

It should be possible to get the message value at least from filename.

It's unlikely I'll get to this in a timely manner because it's simply not very high priority. I'd love to see a PR for it thought ๐Ÿ‘

Thanks for the heads up! It might also take a while for me to free some time, but it's not a big inconvenience, so totally fine for it to wait :)

Can I take this up ?

No objections from my side :)

Sure ๐Ÿ‘