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

Support the ability to add changes to an on-going migration #249

Open
trobertson-cn opened this issue Jan 24, 2024 · 2 comments
Open

Support the ability to add changes to an on-going migration #249

trobertson-cn opened this issue Jan 24, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@trobertson-cn
Copy link

We have a case where a typical development/release cycle will have dozens of commits by multiple developers over the course of days/weeks/months. While it would be preferable to clearly identify all schema changes up front during a cycle, it isn't really practical due to a number of factors. This means that over the course of a cycle, there will be multiple commits with changes to the same schema.
Using pgroll, we could treat each commit as its own migration, but we would prefer to treat all of the changes to a schema in a release as a single migration so that we have a clear A/B differentiation between those releases. For our test and local development systems, this poses a problem because the "continuous-delivery" nature of these systems means that per-commit schema changes have to be applied as the code is pulled/deployed. It would be great if pgroll would allow a migration to "start" and have then have additional schema changes "appended" before eventually being completed at the end of the development cycle for a given release.

@exekias
Copy link
Member

exekias commented Jan 25, 2024

Thanks for opening this issue!

This is a very interesting use case, my understanding is that we want several devs / teams to have in-flight migrations in parallel. The obvious challenges are:

I believe this should be possible to solve, we would need to keep track of all schema expansions and ensure the contract phase happens only after all references to the changed columns/tables are gone. To achieve this, every single migration would need to provide a pointer to what their base version is, so we know any old version without references can be contracted.

@exekias exekias added the enhancement New feature or request label Jan 25, 2024
@trobertson-cn
Copy link
Author

Thanks. I agree that #239 will quickly become necessary as it is quite possible the same "object" will be manipulated multiple times with our model.

I had envisioned this working like an open ledger of changes that could be appended to during the expansion phase. The thought being that there would be a single "ordered" list of changes without the notion of branching. Eventually we would "close" the expansion phase but I don't know if this would be strictly necessary from a usage perspective prior to the contraction, since the contraction would implicitly close the expansion phase.
To keep this manageable, I would expect that any change that was added to the ledger for a given expansion would be immutable and then pgroll would need some way to enforce that as well as identify and sequence the new changes being appended. Clients using the expanded schema would be responsible for adopting the changes as they're added to the ledger and rolled out.

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

No branches or pull requests

2 participants