-
Notifications
You must be signed in to change notification settings - Fork 18
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 enum value for decapitation game mode #316
base: develop
Are you sure you want to change the base?
Add enum value for decapitation game mode #316
Conversation
bb09ab3
to
185f175
Compare
According to this SO article it should work since it's only single digit. Needs a matching change in the API, but I'm all in for cleaning types. |
I think simply updating the column with the new enum values would work since the index is related to the definition order. I don’t think any row updates are needed since we don’t need to change the order of the enum. https://mariadb.com/kb/en/enum/ |
185f175
to
97998f1
Compare
@Brutus5000 is this good to go? |
Totally forgot about this one. I want to test this on the test server to ensure it works with server and api. |
@Askaholic short update: this breaks the API. It now always returns null for victoryCondition 😞 |
@Askaholic Actually the problem is different. Your change drops the values, even though it is non null. I ran it against the test-data.sql After the statement it is in an inconsistent state!
I prepared the required changes in the API but you will have to find a working migration. |
Ok, I’ll have to look into it more then |
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.
Setting this to "changes requested" for correct status reporting
6f35a18
to
96fd568
Compare
96fd568
to
4c2ae15
Compare
Changed it to the approach described here: https://dba.stackexchange.com/questions/6547/can-i-rename-the-values-in-a-mysql-enum-column-in-one-query I was hoping you could do the rename without having to update the rows in the table, but it does not appear to be possible without some hacky stuff. The game stats table is pretty big so it will have to update a lot of rows. |
I'm not sure if we can safely remove the old enum values ever. |
I'm not really sure what safety concerns you are having and how making an entirely new column would address those, but I'm also all for renaming the column to Were you thinking of dropping the column in a separate migration/PR? |
Because every enum member is mapped to an id, what happens if you drop the first value from the enum list? It's actually not documented. could be that all values get "shifted" because just the enum<->id mapping shifts. Anyway. I thought about keeping the old column for potentially rolling back. But that wouldn't work because the new version of the python client would need to populate both. But if it populates both we can't remove the old column either. So let's just drop it right after. In case of a rollback we do a whole db rollback. |
Yes, so I actually was wondering the same thing before I made this PR and I actually tested it in my faf-db container locally with a scratch table. The ids are updated to match the order of the enum. So after the migration is complete the mapping would be:
It seems that Maria will update the underlying ID values when you alter the column so that the ids match the order of the enum definition and any string values are still preserved. That’s why my first attempt at this PR didn’t work, because the old string values were wiped away so Maria didn’t know what the int values should be and replaced them all with nulls. |
Needed for FAForever/fa#5347
Can we change the enum to be the actual string names of the victory conditions without it messing up the historical data? Seems pretty bad to me to be using stringified integers.