Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running statements that can't be run as a multi-command string #81

Open
stevehogdahl opened this issue Dec 17, 2021 · 2 comments
Open

Comments

@stevehogdahl
Copy link

When updating an enum multiple values can't be added at the same time so it requires one update statement per value. Altering types in postgres can't be done a mutli-command string which is how the migrations are executed. This requires one migration file per alter statement which can inflate the number of migration files by quite a lot. We've already run into this issue with two different enum causing us to create 9 different migration files. Is it possible to add a feature to allow multiple single queries with a comment between each to break up the multi-command strings?

Example:

-- postgres-migrations disable-transaction
ALTER TYPE test_type ADD VALUE 'Manual';
ALTER TYPE test_type ADD VALUE 'Automatic';

Error:
ALTER TYPE ... ADD cannot be executed from a function or multi-command string

@ThomWright
Copy link
Owner

Interesting case! Thanks for the issue.

I must admit, my time for maintenance on this library is minimal, so it's unlikely I'll spend time implementing this.

That said, this is a case I would consider support for.

I'd happily discuss a proposal on how this would look, and if we can agree on a design I would accept a PR with:

  • implementation
  • tests
  • docs

As part of a proposal I would like to hear how other libraries in this space (including other languages) handle this problem. If this is a solved problem elsewhere I'd like to know about it first before committing to a design.

@stevehogdahl
Copy link
Author

Thanks for getting back to me so quickly. Sounds good, I'm more than happy to look into this and propose an implementation design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants