rubenv / rubenv/sql-migrate

Multiple `migrate Up` blocks in a single file?

Open
#244 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

Can you have multiple -- +migrate Up blocks within a single file?

I'm specifically wondering about mixing transactional and non-transactional migrations.

ie,

-- +migrate Up
. . .

-- +migrate Up notransaction
. . .

-- +migrate Up
. . .

-- +migrate Down
. . .

As an example use case, I'd like to:

  • create some tables within a transaction
  • concurrently create some indexes (which postgres requires happens outside of a transaction)
  • use the new indexes to create some constraints (this can again happen within a transaction)

I'm currently looking at creating multiple migration files, but if it's possible to simply put them all in a single file then that seems like a much better solution.

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

The issue names no files, tests, or entry points. Start by tracing how -- +migrate Up and notransaction blocks are parsed and executed, then test the three-block example against PostgreSQL. Done means the supported behavior is established and covered by documentation or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.