-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Remove thing_type
and thing_id
columns from settings table
#31971
Remove thing_type
and thing_id
columns from settings table
#31971
Conversation
Yes. They would need to be deleted. And the new index built before the previous one gets deleted. |
524990c
to
311d2c1
Compare
Updated migration to:
There's a (legit, I think) issue here with an old migration picked up by the historical migrations test, as side effect of using the |
9996da2
to
1423747
Compare
Updated old migration to add YAML value wrapper to Setting class, which I think mirrors the behavior expected at that point in time. (Also, this is ~2YO migration, seems low risk to modify, but does keep migration test happy). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible issue is that the post-deployment migration is potentially long and complex, which means increased risk of it failing or being interrupted mid-way, and it disabling transactions means re-running it may be an issue.
Otherwise it looks good to me, but I'd probably wait after 4.3 at that point.
Yeah ... strong migrations wanted the "concurrently" on the index addition, which also required the disable ddl line. One workaround there might be to put JUST the addition of that index in it's own (earlier) migration with disable_ddl, and then everything else in a transaction-wrapped migration to follow up after? Would make the "what do I need to re-run" easier to find if anyone hits interruption issues.
Yes. |
Wouldn't the deletion need to happen before creating the index, though? Otherwise you'd have conflicts for every user variable. |
Ah, yes good catch ... you'd need a) transaction-wrapped delete migration, b) transaction-disabled concurrent index addition, c) transaction wrapped the rest. Three migrations seems overkill for the changes. |
This pull request has merge conflicts that must be resolved before it can be merged. |
1423747
to
7b0c94c
Compare
This pull request has resolved merge conflicts and is ready for review. |
7b0c94c
to
49608f7
Compare
49608f7
to
7e0e529
Compare
800b4c0
to
7529205
Compare
On this one - I know we were in wait until post-4.3 mode, but I dont know if the issues re: migration setup were resolved or not, or if theres still more to do? |
This is rather awkward, but… I think we need to delete the However, this also means you can't safely upgrade anymore from a pre-4.2.0 version to a version with this zero-downtime migration. This is already a restriction we have since the 4.3.0 release because of the cookies change, and it's not the first time we are hitting such roadblocks, so maybe it's time to formalize such “breakpoints” and have e.g. some additional pre-migration check to ensure you've reached a specific breakpoint before running any more migrations with |
We have |
Yes, that's my concern. There are some variables with overlap between system variables and user variables: |
Hmm, yeah. Looking throught the diff here, I think...
It's really only the itneraction between the scope and the migration that has timing/dependency issues. We currently have a mix of setting records:
If we pull out the scope before running the migration, we'll hit (old, unused) user settings for some where names collide. If we run the migration first w/out changing scope, once the migration finishes the scope will be referring to now-nonexistent columns are start erroring. What if we...
|
We're currently using them in the default scope.
As I said earlier, this should be pre-deployment migration (otherwise new code will pick up the old values). But it requires 4.2.0 code to be running otherwise new records with non-nil columns may be created. Therefore I think this first step still needs a breakpoint, such as what I'm proposing in #33089 But such a breakpoint already exists because of the cookies migration, even if it's not enforced by a task check. |
Wont the scope keep including them in the where clause even if they are in ignored_columns?
Yes, if we pulled out the deletion portion only to stand alone migration that could be normal migration.
I'll check that one out ... isn't there already a policy/guideline of "you must have migrated all the way to end of a last minor version before bumping to next one"? Maybe that's not code enforced - but that's the expectation, right?
👍 |
7529205
to
0edc9f3
Compare
I haven't tried, but I don't think so.
No, that is not. On the contrary, we try to support skipping version updates, if only because sometimes intermediary versions become uninstallable for one reason or another. But I think it's reasonable to not support zero-downtime migrations when skipping versions. |
Running with the default scope, but without the ignored columns...
When I add the ignored columns...
So - looks like ignored columns changes the selected columns from
Fun. |
0edc9f3
to
240bc24
Compare
240bc24
to
aac3447
Compare
I'm mostly sure (based on code comments and commit history) we want to do this, but less sure about WHEN to do this. If this is ready to be done now, go ahead and review ... if not, wait until post-4.3 (or even later?) release.
The history here I believe is that at one point user settings were stored one setting per row in this table, but have since migrated over to a (text)
settings
column on users table (wrapped by custom JSON coder at ruby level), leaving thissettings
table to just handle the site-wide setting values (theSetting
model has a default scope to operate only where these columns are null).Things to confirm:
var
, which I assume is desirable for the app-wide settings.