sql-migrate icon indicating copy to clipboard operation
sql-migrate copied to clipboard

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

Open Sequoia opened this issue 6 years ago • 1 comments

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

  • Both up and down migrations are run
  • Table foo does not exist

Sequoia avatar Mar 01 '19 18:03 Sequoia

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 👍

Sequoia avatar Mar 01 '19 18:03 Sequoia