-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add reversed actions when using reverse #87
base: master
Are you sure you want to change the base?
Conversation
Looks like this is breaking a ton of stuff...hmmmm |
So it looks like reverse is reversing within an operation (as evident by the tests) but it's not reversing when chaining operations |
Can you confirm that your test fails without the change and passes with it? |
@nafg I think I actually identified the root cause as https://github.com/nafg/slick-migration-api/blob/master/src/main/scala/slick/migration/api/Dialect.scala#L184 Sorting by the Action sort value is forcing order regardless of the appended order of the actions. Removing the |
Thanks for investigating this. I had forgotten about P.S. Why is GitHub showing a changed line in build.sbt? |
The alignment of all the dependency versions were correct except for that one haha. |
@nafg yeah so my proposed solution was to add a I'm using this locally right now and it works as expected. Does this solution seem good to you? |
Ok @nafg this should be good if you're ok with the solution. It looks like on every db except Postgres, you can't create, add and then remove all columns (there must be at least one). Not sure if that should be noted anywhere but this now acts as expected. I added a test to that end that passes. I wasn't sure if there was much else you wanted added in the tests beyond this. |
Can you comment on this suggestion?
|
@nafg Ah sorry I think I had mis-understood what you were originally talking about. I played around with the weights (sort values) and have verified locally it now works for me. Is this more of what you were thinking? |
Yes, thanks.
Do you mind explaining the tests in more detail?
…On Sun, Jun 28, 2020 at 10:21 PM Matt Oliver ***@***.***> wrote:
@nafg <https://github.com/nafg> Ah sorry I think I had mis-understood
what you were originally talking about. I played around with the weights
(sort values) and have verified locally it now works for me. Is this more
of what you were thinking?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#87 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAYAUGGYR3FOEN7ALPR6G3RY73BDANCNFSM4OIVY7PQ>
.
|
It tests that a successful reversal of multiple chained migrations works. All of the other test examples, afaik, only test the reversal of one migration. Due to db mechanics for the various kinds though, Postgres is the only db that can drop all columns. All the others throw and error stating that you must have at least one column present. This test ensures that at least Postgres can do a compete reversal, as the others throw and we just continue on. I’m open to removing it though since really the only thing we’re testing is Postgres succeeding. |
Should .reverse just be smarter and if it's reversing a create table skip
reversing create columns?
…On Mon, Jun 29, 2020, 9:28 AM Matt Oliver ***@***.***> wrote:
It tests that a successful reversal of multiple chained migrations works.
All of the other test examples, afaik, only test the reversal of one
migration.
Due to db mechanics for the various kinds though, Postgres is the only db
that can drop all columns. All the others throw and error stating that you
must have at least one column present.
This test ensures that at least Postgres can do a compete reversal, as the
others throw and we just continue on. I’m open to removing it though since
really the only thing we’re testing is Postgres succeeding.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#87 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAYAUETOS6I3A5Y57FH6TLRZCJIBANCNFSM4OIVY7PQ>
.
|
We could detect a drop table and then just drop any drop column actions from the actions list...we probably could just drop all other actions since dropping the table is the most final action of all actions. I'm not sure that's the most prudent way to go about it though, seems somewhat brute-forcy. I'm using Postgres personally, so I'm unaffected by the last column rule. |
I hear, I just don't like the idea of a test using isInstanceOf and
try/catch like that, it seems like it's much less clear that everything
works 100%.
Some things, like indexes, I'm not sure if dropping the table "includes"
dropping them -- might it need a CASCADE? Or am I thinking of something
else? Anyway they are separate, top-level objects, while columns are part
of a table. So while dropping an index might be necessary and implied by
dropping the table, it's still a distinct action. On the other hand,
dropping columns and then the table is just dropping part of a thing and
then the rest. Dropping columns isn't *implied* by dropping the table, it's
*included* in it.
And that's besides the fact that apparently outside of postgres dropping
all the columns is an *error*, while nothing else is.
So in short, for multiple reasons it's not crazy to "drop" the drop-columns
when there's a drop-table too.
What do you think?
…On Mon, Jun 29, 2020 at 12:33 PM Matt Oliver ***@***.***> wrote:
We could detect a drop table and then just drop any drop column actions
from the actions list...we probably could just drop all other actions since
dropping the table is the most final action of all actions. I'm not sure
that's the most prudent way to go about it though, seems somewhat
brute-forcy.
I'm using Postgres personally, so I'm unaffected by the last column rule.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#87 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAYAUAOHXRJAQGPH24JFWLRZC64HANCNFSM4OIVY7PQ>
.
|
Yeah I think that's a fine approach. So you'd detect whether a drop table action has been queued and then essentially remove any drop column actions and proceed as normal. |
Hi, do you plan to implement this? |
@nafg I don't have a lot of time right now unfortunately. I found a solution I can live with in my project for now. If I find some time in the future, I'll be able to revisit this if it's not already fixed. |
24176d9
to
4373aa5
Compare
@nafg Hi Naftoli, I just ran into this issue as well. If you can help me understand what's still needed to get a solution over the finish line, I'd be happy to work on it. |
@anovstrup would you be interested in pair programming it with me? IIRC it wouldn't be much work but I have to context-switch back into it |
Sure! I probably won't be available until late this week (Thursday or Friday). Sounds like this is what's left to implement, plus any additional testing that's needed?
|
Great, can you message me on Discord?
I would have to refresh my memory ;) |
Reverses the Action order of operations when using reverse.
Closes #86