Semicolon after `-- +migrate Down` quietly runs BOTH migrations on `up`
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 3.4k
- Forks
- 292
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the migration with sql-migrate up, then inspect the migration-directive parsing entry point that handles -- +migrate Up and -- +migrate Down;. Verify the fix with the provided PostgreSQL example: foo should remain after up, or the invalid semicolon syntax should be rejected without running both sections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100