sql-migrate
sql-migrate copied to clipboard
Semicolon after `-- +migrate Down` quietly runs BOTH migrations on `up`
Reproduction
- PostgreSQL 11.2 (Debian 11.2-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
- psql (PostgreSQL) 11.1
Input migration
-- +migrate Up
CREATE TABLE foo( id uuid PRIMARY KEY );
-- +migrate Down;
DROP TABLE foo;
- Run
sql-migrate up - Connect to database with
psql - Run postgres command
\dtto show tables
Expected outcome
Either:
A) Table foo exists, or
B) sql-migrate complains about the bad syntax and aborts migration
Actual outcome
- Both up and down migrations are run
- Table
foodoes not exist
Removing the semicolon after Down fixes the issue, but this took me a good bit of trial and error to figure out. I'd send a failing test but I'm very new to Go. Thanks 👍