rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.24k stars 280 forks source link

Semicolon after `-- +migrate Down` quietly runs BOTH migrations on `up` #132

Open Sequoia opened 5 years ago

Sequoia commented 5 years ago

Reproduction

Input migration

-- +migrate Up

CREATE TABLE foo( id uuid PRIMARY KEY );

-- +migrate Down;

DROP TABLE foo;
  1. Run sql-migrate up
  2. Connect to database with psql
  3. Run postgres command \dt to show tables

Expected outcome

Either: A) Table foo exists, or B) sql-migrate complains about the bad syntax and aborts migration

Actual outcome

Sequoia commented 5 years ago

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 👍