rubenv / rubenv/sql-migrate

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

Open
#132 1 comment 0 reactions 0 assignees View on GitHub

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.