Open
Conversation
### Why direction of migration is required Imagine this steps: V1 | V2 | V3 --- | --- | --- X | Y:RX | X Where `X` is column name, `Y:RX` is column with `Y` name and `reanmed_from` property set to `X` name. ### What happens when we generate migration scripts Migration | Diff result `[src, tar]` | Description --- | --- | --- v1 -> v2 | X, Y:RX | This works well. The `X` was renamed to `Y`. v2 -> v3 | Y:RX, X | This is also expected. The `Y` was dropped and `X` was created. v2 -> v1 | Y:RX, X | For downgrade script it is not expected that `Y` will be dropped and `X` will be created from scratch. During migration `v1->v2` it was renamed and now durint `v2->v1` we expect it should be renamed back. But this drop happens because it works as designed for `upgrade` direction. But this scenario it is `downgrade`. Unfortunately We can not detect this automatically: the order of `[src, dst]` is the same and the set of `extra` properties are the same. (For now I am skipping more complex scenarios when `v3` migration has columns with created and/or renamed names similar to `v2` version and its consequences on `v1`) ### Proposition From the above to get the expected result during `downgrades` we need to pass the direction that the `downgrade` migration should be generated.
4ec1d40 to
b218b54
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why direction of migration is required
Imagine this steps:
Where
Xis column name,Y:RXis column withYname andreanmed_fromproperty set toXname.What happens when we generate migration scripts
[src, tar]Xwas renamed toY.Ywas dropped andXwas created.Ywill be dropped andXwill be created from scratch. During upgrade migrationv1->v2it was renamed and now during downgradev2->v1we expect it should be renamed back. But instead the drop happens because it works as designed forupgradedirection. But this scenario it isdowngrade. Unfortunately We can not detect this automatically: the order of[src, dst]is the same and the set ofextraproperties are the same.Proposition
From the above to get the expected result during
downgradeswe need to pass the flag that thedowngrademigration should be generated.