Message header lost on commit error
- Dominant language
- TypeScript
- Stars
- 835
- Forks
- 64
- Avg merge
- 17m
- Merged PRs (30d)
- 5
Description
### 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:
```sql
--! 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:

### Expected results
Have contents of `current.sql` the same as before failure:
```sql
--! 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:
```sql
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
```text
graphile-migrate[shadow]: Running migration '000002-test-migration.sql'
```
It should be possible to get the message value at least from filename.
Contributor guide
Assessment
This issue has not been assessed yet.