graphile / graphile/migrate

Message header lost on commit error

Open
#119 5 comments 0 reactions 1 assignee Claimed by @hionnode View on GitHub
bug good first issue
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:
![image](https://user-images.githubusercontent.com/37663061/117626303-9f821f00-b17f-11eb-8e7d-785599cf47e0.png)

### 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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.