-
Notifications
You must be signed in to change notification settings - Fork 5k
Ban database refactor #42495
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
Ban database refactor #42495
Conversation
Supports all the new functionality (multiple players/addresses/hwids/roles/rounds per ban).
The server ID check is no longer done as admins may want to place bans spanning multiple rounds irrelevant of the source server.
|
Marking as draft since I still want to do more testing. Also I need to rebase this onto stable so we can do the server update. |
f637bb8 to
390d7f2
Compare
Not relevant, reduces query performance
Would blow up handling null player records. Not a new bug introduced by the refactor, but I ran into it.
VasilisThePikachu
left a comment
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.
I will do a review later however quick thing I noticed
Please update the deletion and data dump scripts to the new schema.
oh yeah fair enough |
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.
Banning multiple departments with the same roles causes the a database exception because the unique index IX_ban_role_role_type_role_id_ban_id gets violated.
An easy way to replicate this is banning someone from command and security
|
The schema looks fine otherwise. The queries could be improved to cut down on roundtrips (because of split queries. The ban table really isn't large enough to require split queries imo) and joins but that is really out of scope for this PR imo |
Most notably happened with role bans, as multiple departments may include the same role.
|
Merge before maintenance starts so that vulture does not start with it before we are ready for the db migration. |
Ban database refactor (#42495) * Ban DB refactor seems to work at a basic level for PostgreSQL * New ban creation API Supports all the new functionality (multiple players/addresses/hwids/roles/rounds per ban). * Make the migration irreversible * Re-implement ban notifications The server ID check is no longer done as admins may want to place bans spanning multiple rounds irrelevant of the source server. * Fix some split query warnings * Implement migration on SQLite * More comments * Remove required from ban reason SS14.Admin changes would like this * More missing AsSplitQuery() calls * Fix missing ban type filter * Fix old CreateServerBan API with permanent time * Fix department and role ban commands with permanent time * Re-add banhits navigation property Dropped this on accident, SS14.Admin needs it. * More ban API fixes. * Don't fetch ban exemption info for role bans Not relevant, reduces query performance * Regenerate migrations * Fix adminnotes command for players that never connected Would blow up handling null player records. Not a new bug introduced by the refactor, but I ran into it. * Great shame... I accidentally committed submodule update... * Update GDPR scripts * Fix sandbox violation * Fix bans with duplicate info causing DB exceptions Most notably happened with role bans, as multiple departments may include the same role.
Ban database refactor (#42495) * Ban DB refactor seems to work at a basic level for PostgreSQL * New ban creation API Supports all the new functionality (multiple players/addresses/hwids/roles/rounds per ban). * Make the migration irreversible * Re-implement ban notifications The server ID check is no longer done as admins may want to place bans spanning multiple rounds irrelevant of the source server. * Fix some split query warnings * Implement migration on SQLite * More comments * Remove required from ban reason SS14.Admin changes would like this * More missing AsSplitQuery() calls * Fix missing ban type filter * Fix old CreateServerBan API with permanent time * Fix department and role ban commands with permanent time * Re-add banhits navigation property Dropped this on accident, SS14.Admin needs it. * More ban API fixes. * Don't fetch ban exemption info for role bans Not relevant, reduces query performance * Regenerate migrations * Fix adminnotes command for players that never connected Would blow up handling null player records. Not a new bug introduced by the refactor, but I ran into it. * Great shame... I accidentally committed submodule update... * Update GDPR scripts * Fix sandbox violation * Fix bans with duplicate info causing DB exceptions Most notably happened with role bans, as multiple departments may include the same role.
Ban database refactor (space-wizards#42495) * Ban DB refactor seems to work at a basic level for PostgreSQL * New ban creation API Supports all the new functionality (multiple players/addresses/hwids/roles/rounds per ban). * Make the migration irreversible * Re-implement ban notifications The server ID check is no longer done as admins may want to place bans spanning multiple rounds irrelevant of the source server. * Fix some split query warnings * Implement migration on SQLite * More comments * Remove required from ban reason SS14.Admin changes would like this * More missing AsSplitQuery() calls * Fix missing ban type filter * Fix old CreateServerBan API with permanent time * Fix department and role ban commands with permanent time * Re-add banhits navigation property Dropped this on accident, SS14.Admin needs it. * More ban API fixes. * Don't fetch ban exemption info for role bans Not relevant, reduces query performance * Regenerate migrations * Fix adminnotes command for players that never connected Would blow up handling null player records. Not a new bug introduced by the refactor, but I ran into it. * Great shame... I accidentally committed submodule update... * Update GDPR scripts * Fix sandbox violation * Fix bans with duplicate info causing DB exceptions Most notably happened with role bans, as multiple departments may include the same role.
About the PR
This refactors the way bans are stored in the database, enabling bans to have multiple players/HWIDs/IPs/rounds/roles per ban. There's also significant code cleanup along the way.
This PR does not update most of the game/tooling to expose this new functionality (eg banning on multiple round IDs), that can be done in separate PRs once the main schema refactor is over with. The one exception is that role bans now make one ban with multiple roles.
Why / Balance
Our admins are weeping because role bans weren't normalized in the DB properly and needed to be separate records per job.
Having multiple players/HWIDs/IPs per ban record enables future sticky ban tracking systems sanely.
Multiple rounds per ban is because I was thinking "well if I'm gonna do a massive DB change might as well be proactive."
Technical details
The DB model has been significantly refactored:
typecolumn on the singlebantable.ProtoId<>more thoroughly in some role ban code.Job:Captain) are now more cleanly typed to avoid confusion.Media
Requirements
Breaking changes
ServerBanDef&ServerRoleBanDef->BanDef).GetBanAsync().ProtoId<>more thoroughly in some role ban code.Job:Captain) are now more cleanly typed asBanRoleDefin C# to avoid confusion.Changelog
🆑
ADMIN: