rubenv / sql-migrate

SQL schema migration tool for Go.
MIT License
3.16k stars 269 forks source link

Multiple `migrate Up` blocks in a single file? #244

Open tjlevel12 opened 1 year ago

tjlevel12 commented 1 year ago

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:

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.

rubenv commented 1 year ago

Nope, just use multiple migrations.

On Wed, May 31, 2023, 19:08 Timothy Warren @.***> wrote:

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.

— Reply to this email directly, view it on GitHub https://github.com/rubenv/sql-migrate/issues/244, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKPGDY37LNKBJGONGVBM3XI53ITANCNFSM6AAAAAAYVYKKCU . You are receiving this because you are subscribed to this thread.Message ID: @.***>