Ability to run migrations without the transaction

Issue #15 new
Gregory Petrosyan created an issue

Some commands (e.g. ALTER TYPE … ADD VALUE in PostgreSQL) can not work inside transactions.

See also: https://github.com/rails/rails/issues/9483

Comments (6)

  1. Liam Staskawicz repo owner

    Oof. Thanks for the report.

    Will need to think about how best to handle the case in which migration succeeds, but the secondary operation to update the schema version number fails...

  2. Sridhar Venkatakrishnan

    I needed this feature as well since I'm using goose to manage database creation. I've put together a small prototype that does the following:

    • It adds a new UnsafeNoTransaction annotation.
    • Only one statement is allowed if this annotation is applied.
    • The user is expected to make that statement idempotent.
    • Version updates still happen inside a transaction.

    This way if the version update fails, it prints a warning that the statement will be run again. Since the statement is idempotent it can be run again safely.

    My prototype for .sql files can be found here:

    https://bitbucket.org/surullabs/goose/commits/398815e71a9e2fd7acbf7407091643e32e1eeeed?at=master

    Let me know if you think this approach is acceptable and I'll clean it up, add some tests and send you a pull request.

    EDIT: grammar

  3. Liam Staskawicz repo owner

    thanks for looking into this! i hope to be able to take a look this weekend and provide some feedback.

  4. Gregory Petrosyan reporter

    @liamstask, what are your plans about this one? It is almost a year since the original report.

  5. Log in to comment