Convert the WellSqlConfig migrations to Kotlin#1395
Conversation
oguzkocer
left a comment
There was a problem hiding this comment.
Thanks for working on this @0nko. I have gone through every single migration and everything seems to be in order except for a single case that seems to be missing the migration. I haven't done a character by character comparison, but I did look through each case from before the change and after it and all of it looked the same. Due to the sensitivity of this PR, I'd suggest at least another dev to look at it, possibly even more, just to be on the safe side. Let me know what you think!
|
Just came by to mention that the unit tests and ktlint were failing but it looks like you fixed them 👍 Nice Kotlinification, this much improves the class 🎉. Other than lint/tests and Oguz's notes this looks good. One thing is that the checkstyle plugin is unhappy with this file and riddles it with newline warnings in the IDE (the actual gradle task passes). Are you seeing that too? Also for testing, I was wondering @0nko @oguzkocer if you've tried running a migration? Something like:
It's probably fine but let's be extra cautious with our migration scripts. I'll try to try this today, if not it'll be next week. |
Right - my suggestion was to use old releases, that way they're already compiled and we don't have to worry about being able to build them. Downside is not debuggable, but that's only an issue if there turns out to be an actual problem 😀 (then we'd need to dig in) |
|
@aforcier @oguzkocer Thanks for the review! I've spent half a day yesterday trying to make the migration run from version 1 work. I found a point where the I also wanted to write a unit test that would run the migration the same way automatically but I haven't figured out how to make it work yet. I've performed some basic testing and things seem to be working. @oguzkocer You can go ahead with another pass. If I'm able to make the unit test work, we can add it later. |
oguzkocer
left a comment
There was a problem hiding this comment.
Thanks for the updates @0nko! I compared the migrations again, this time I didn't do all of it, but instead just compared about 30% of it. Everything looked good to me.
I also installed 2 old builds, one very old, one about 1 year old and then updated it with the apk built with the changes (thanks to @jkmassel 🙇 ) and in both cases the migration worked fine and my data (posts, pages & comments) was preserved.
I think we can 🚢 it but I'd feel better if @aforcier could also take another look with how important migrations are.
|
@aforcier, would you mind taking another look? I think it should be good, but just in case. :) |
|
I tested migrating (to a build using the tip of this branch) from a few older WPAndroid versions and one WooAndroid version:
In all cases the migrations ran and were logged correctly, and drafts/data seemed to be preserved. There's a small problem though - this currently is a breaking change for WPAndroid (in debug but not in release) and WooAndroid (any build). The breaking classes are WPWellSqlConfig and WooWellSqlConfig. There are two causes:
|
|
Ah yes, I saw those breaks as well in WPAndroid, but didn't think it would be big deal. I should have mentioned it though since we want to have PRs ready to be merged when this change is merged to |
|
Thanks for pointing it out, Alex! I added the original reset method with the helper parameter, which was needed for the downgrades. I've created a PR in each repo, ready for review/merge. |
|
Looks good and so do the counterpart PRs - merging this and leaving the Woo and WP PRs open so you can update the tag before those merge.
|
After fixing #1393, I've been thinking about how to make the migrations safer and less error-prone. I've converted the
WellSqlConfigclass to Kotlin and extracted some repetitive code, which should help. What do you think?I've copied over the SQL scripts but just to be safe, I'd like to ask the reviewer to double check that everything correct.