Delta-v/Content.Server.Database/Migrations/Postgres
Pieter-Jan Briers 8e8a4cf1b6
Fix database round start date issues (#26838)
How can ONE DATABASE COLUMN have so many cursed issues I don't know, but it certainly pissed off the devil in its previous life.

The start_date column on round entities in the database was added by https://github.com/space-wizards/space-station-14/pull/21153. For some reason, this PR gave the column a nonsensical default value instead of making it nullable. This default value causes the code from #25280 to break. It actually trips an assert though that's not what the original issue report ran into.

This didn't get noticed on wizden servers because we at some point backfilled the start_date column based on the stored admin logs.

So I change the database model to make this column nullable, updated the C# code to match, and made the existing migration set the invalid values to be NULL instead. Cool.

Wait how's SQLite handle in this scenario anyways? Well actually turns out the column was *completely broken* in the first place!

The code for inserting into the round table was copy pasted between SQLite and PostgreSQL, with the only difference being that the SQLite key manually assigned the primary key instead of letting SQLite AUTOINCREMENT it. And then the code to give a start_date value was only added to the PostgreSQL version (which is actually in the base class already). So for SQLite that column's been filled up with the same invalid default the whole time.

Why was the code manually assigning a PK? I checked the SQLite docs for AUTOINCREMENT[1], and the behavior seems appropriate.

I removed the SQLite-specific code path and it just seems to work regardless. The migration just sets the old values to NULL too.

BUT WAIT, THERE'S MORE!

Turns out just doing the migration on SQLite is a pain in the ass! EF Core has to create a new table to apply the nullability change, because SQLite doesn't support proper ALTER COLUMN. This causes the generated SQL commands to be weird and the UPDATE for the migration goes BEFORE the nullability change... I ended up having to make TWO migrations for SQLite. Yay.

Fixes #26800

[1]: https://www.sqlite.org/autoinc.html

(cherry picked from commit d3ac3d06bb6eddd9c2076a586974aabf514a5c86)
2024-04-21 21:57:13 +02:00
..
20200929113117_Init.Designer.cs Holy crap auth works (#2099) 2020-09-29 14:26:00 +02:00
20200929113117_Init.cs Holy crap auth works (#2099) 2020-09-29 14:26:00 +02:00
20201006223000_SelectedCharacterSlotFk.cs Foreign key for selected character slots. 2020-10-07 10:42:53 +02:00
20201028210620_Admins.Designer.cs ConGroups are gone. Long live admin flags in content. 2020-10-30 16:06:48 +01:00
20201028210620_Admins.cs ConGroups are gone. Long live admin flags in content. 2020-10-30 16:06:48 +01:00
20201109092921_ExtraIndices.Designer.cs Permissions panel. 2020-11-10 16:50:28 +01:00
20201109092921_ExtraIndices.cs Permissions panel. 2020-11-10 16:50:28 +01:00
20201203093409_ClothingAndPronouns.Designer.cs Clothing and pronoun fields (#2689) 2020-12-24 14:42:40 +01:00
20201203093409_ClothingAndPronouns.cs Clothing and pronoun fields (#2689) 2020-12-24 14:42:40 +01:00
20210103151756_BackpackPreference.Designer.cs Backpack preferences. (#2864) 2021-01-03 16:22:14 +01:00
20210103151756_BackpackPreference.cs Backpack preferences. (#2864) 2021-01-03 16:22:14 +01:00
20210211211033_AdminOOCColor.Designer.cs OOC sent by an admin will have a different color (#3117) 2021-02-14 15:59:56 +01:00
20210211211033_AdminOOCColor.cs OOC sent by an admin will have a different color (#3117) 2021-02-14 15:59:56 +01:00
20210321230012_HWID.Designer.cs Use HWIDs for bans. 2021-03-22 01:32:09 +01:00
20210321230012_HWID.cs Cleanup the namespaces (#8132) 2022-05-13 17:59:03 +10:00
20210915093340_UniqueHighPriorityJob.Designer.cs Add extra unique constraints to DB jobs. 2021-09-15 11:37:05 +02:00
20210915093340_UniqueHighPriorityJob.cs Add extra unique constraints to DB jobs. 2021-09-15 11:37:05 +02:00
20211120202701_AdminLogs.Designer.cs THE RETURN OF THE KING 2021-11-22 19:08:27 +01:00
20211120202701_AdminLogs.cs THE RETURN OF THE KING 2021-11-22 19:08:27 +01:00
20211121123543_AdminLogsImpact.Designer.cs THE RETURN OF THE KING 2021-11-22 19:08:27 +01:00
20211121123543_AdminLogsImpact.cs THE RETURN OF THE KING 2021-11-22 19:08:27 +01:00
20220103235647_whitelist.Designer.cs Rename migrations to fix CS8981 warnings. (#14160) 2023-02-19 10:59:52 +11:00
20220103235647_whitelist.cs Rename migrations to fix CS8981 warnings. (#14160) 2023-02-19 10:59:52 +11:00
20220108185749_add-species.Designer.cs Rename migrations to fix CS8981 warnings. (#14160) 2023-02-19 10:59:52 +11:00
20220108185749_add-species.cs Rename migrations to fix CS8981 warnings. (#14160) 2023-02-19 10:59:52 +11:00
20220127170845_UnifyMore.Designer.cs Unify remaining DB model classes between SQLite and Postgres. 2022-01-27 18:12:09 +01:00
20220127170845_UnifyMore.cs Unify remaining DB model classes between SQLite and Postgres. 2022-01-27 18:12:09 +01:00
20220129005644_ServerBanHit.Designer.cs Revert "Revert "Log ban hits in DB. ( (#6361) 2022-02-02 22:57:11 +01:00
20220129005644_ServerBanHit.cs Revert "Revert "Log ban hits in DB. ( (#6361) 2022-02-02 22:57:11 +01:00
20220214061058_RoleBans.Designer.cs Role bans (#6703) 2022-02-21 23:11:39 +01:00
20220214061058_RoleBans.cs Role bans (#6703) 2022-02-21 23:11:39 +01:00
20220308222742_Cleanup.Designer.cs Fix database model migrations after role bans. 2022-03-08 23:36:02 +01:00
20220308222742_Cleanup.cs Fix database model migrations after role bans. 2022-03-08 23:36:02 +01:00
20220310173734_SpeciesMarkings.Designer.cs Markings (#7072) 2022-05-05 10:07:42 +02:00
20220310173734_SpeciesMarkings.cs Markings (#7072) 2022-05-05 10:07:42 +02:00
20220313151800_ServerNameFts.Designer.cs Server names and admin log full-text search (#6327) 2022-03-13 18:36:48 +01:00
20220313151800_ServerNameFts.cs Server names and admin log full-text search (#6327) 2022-03-13 18:36:48 +01:00
20220324144654_AdminNotes.Designer.cs Admin notes (#7259) 2022-04-16 20:57:50 +02:00
20220324144654_AdminNotes.cs Admin notes (#7259) 2022-04-16 20:57:50 +02:00
20220325170225_PlayerReadRules.Designer.cs Track rule reading in database, don't show popup locally (#7278) 2022-03-26 20:16:57 +01:00
20220325170225_PlayerReadRules.cs Track rule reading in database, don't show popup locally (#7278) 2022-03-26 20:16:57 +01:00
20220326104916_UploadedResourcesLog.Designer.cs Adds Network Resource Uploading for admins. (#6904) 2022-03-26 12:46:37 +01:00
20220326104916_UploadedResourcesLog.cs Adds Network Resource Uploading for admins. (#6904) 2022-03-26 12:46:37 +01:00
20220503222955_FixIndices.Designer.cs Fix admin log indices. (#7920) 2022-05-04 16:18:55 +02:00
20220503222955_FixIndices.cs Fix admin log indices. (#7920) 2022-05-04 16:18:55 +02:00
20220505084828_MarkingsJsonb.Designer.cs Make Profile.Markings db column jsonb (#7947) 2022-05-05 11:23:48 +02:00
20220505084828_MarkingsJsonb.cs Make Profile.Markings db column jsonb (#7947) 2022-05-05 11:23:48 +02:00
20220509060724_FlavorText.Designer.cs Flavor text (#8070) 2022-05-13 15:58:45 -07:00
20220509060724_FlavorText.cs Flavor text (#8070) 2022-05-13 15:58:45 -07:00
20220724000132_PlayTime.Designer.cs Play time tracking: Job timers 3: more titles: when the (#9978) 2022-08-07 16:00:42 +10:00
20220724000132_PlayTime.cs Play time tracking: Job timers 3: more titles: when the (#9978) 2022-08-07 16:00:42 +10:00
20220816163319_Traits.Designer.cs Implement traits system (#10693) 2022-09-10 08:40:06 -07:00
20220816163319_Traits.cs Implement traits system (#10693) 2022-09-10 08:40:06 -07:00
20230319110655_ProfileTraitIndexUnique.Designer.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230319110655_ProfileTraitIndexUnique.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230319112124_ServerBanExemption.Designer.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230319112124_ServerBanExemption.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230402214647_BanAutoDelete.Designer.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230402214647_BanAutoDelete.cs Server ban exemption system (#15076) 2023-04-03 10:24:55 +10:00
20230503001749_AdminNotesImprovement.Designer.cs Better notes and bans (#14228) 2023-07-21 13:38:52 +02:00
20230503001749_AdminNotesImprovement.cs Admin notes bugfixes (#18189) 2023-07-21 15:43:47 +02:00
20230725193102_AdminNotesImprovementsForeignKeys.Designer.cs GDPR stuff update (#18300) 2023-07-26 20:05:51 +02:00
20230725193102_AdminNotesImprovementsForeignKeys.cs GDPR stuff update (#18300) 2023-07-26 20:05:51 +02:00
20230727190902_AdminLogCompoundKey.Designer.cs Remove autogenerated from admin log key. (#18377) 2023-07-29 16:44:28 +10:00
20230727190902_AdminLogCompoundKey.cs Remove autogenerated from admin log key. (#18377) 2023-07-29 16:44:28 +10:00
20231021071411_RoundStartDate.Designer.cs Store round start date in the database (#21153) 2023-10-23 23:54:01 +02:00
20231021071411_RoundStartDate.cs Store round start date in the database (#21153) 2023-10-23 23:54:01 +02:00
20231024041204_DropAdminLogEntity.Designer.cs Drop admin log entity db table (#21216) 2023-10-24 18:03:52 +02:00
20231024041204_DropAdminLogEntity.cs Drop admin log entity db table (#21216) 2023-10-24 18:03:52 +02:00
20231126234054_ConnectionLogServer.Designer.cs Log server ID in connection logs table (#21911) 2023-12-16 19:27:08 +01:00
20231126234054_ConnectionLogServer.cs Log server ID in connection logs table (#21911) 2023-12-16 19:27:08 +01:00
20231226154937_AdminLogPk.Designer.cs Fix admin log key order. (#23052) 2024-01-26 22:26:15 +01:00
20231226154937_AdminLogPk.cs Fix admin log key order. (#23052) 2024-01-26 22:26:15 +01:00
20240201091301_SpawnPriorityPreference.Designer.cs Client customization late-join spawner priority for arrivals/cryostorage (#24586) 2024-02-08 12:16:20 +01:00
20240201091301_SpawnPriorityPreference.cs Client customization late-join spawner priority for arrivals/cryostorage (#24586) 2024-02-08 12:16:20 +01:00
20240318022005_AdminMessageDismiss.Designer.cs Improve admin message seen/dismiss state. (#26223) 2024-03-24 00:08:01 +01:00
20240318022005_AdminMessageDismiss.cs Fix missing semicolon after migration. (#26337) 2024-03-24 00:13:47 +01:00
20240409013837_FixRoundStartDateNullability.Designer.cs Fix database round start date issues (#26838) 2024-04-21 21:57:13 +02:00
20240409013837_FixRoundStartDateNullability.cs Fix database round start date issues (#26838) 2024-04-21 21:57:13 +02:00
PostgresServerDbContextModelSnapshot.cs Fix database round start date issues (#26838) 2024-04-21 21:57:13 +02:00