Skip to content

Support running multiple statements per migrations file #3693

Open
@adriangb

Description

@adriangb

I have found these related issues/pull requests

#3181 introduced a --no-transaction directive specifically so that things like CREATE INDEX CONCURRENTLY or CREATE DATABASE could be run on Postgres.

Description

But if you include more than one statement in a query Postgres starts an implicit transaction, which means that you can only run a single statement per migration file. This quickly becomes frustrating.

Prefered solution

I propose the addition of a -- sqlx: split migration directive that allows doing something like this:

-- no-transaction
CREATE INDEX CONCURRENTLY ...
-- sqlx: split migration
CREATE INDEX CONCURRENTLY ...

Then sqlx literally calls split() on the migration string and runs multiple queries instead of a single one.

Is this a breaking change? Why or why not?

I don't think it has to be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions