Foreign key for selected character slots.

This commit is contained in:
Pieter-Jan Briers
2020-10-07 10:35:38 +02:00
parent 0532811744
commit 20eac0de84
3 changed files with 25 additions and 6 deletions

View File

@@ -55,6 +55,12 @@ namespace Content.Server.Database
[Table("preference")]
public class Preference
{
// NOTE: on postgres there SHOULD be an FK ensuring that the selected character slot always exists.
// I had to use a migration to implement it and as a result its creation is a finicky mess.
// Because if I let EFCore know about it it would explode on a circular reference.
// Also it has to be DEFERRABLE INITIALLY DEFERRED so that insertion of new preferences works.
// Also I couldn't figure out how to create it on SQLite.
[Column("preference_id")] public int Id { get; set; }
[Column("user_id")] public Guid UserId { get; set; }
[Column("selected_character_slot")] public int SelectedCharacterSlot { get; set; }