diff options
Diffstat (limited to 'HBContext.cs')
| -rw-r--r-- | HBContext.cs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/HBContext.cs b/HBContext.cs index 4334495..2bb477e 100644 --- a/HBContext.cs +++ b/HBContext.cs @@ -9,10 +9,13 @@ enum HBObjectId { AdminUser = -3 } -public class HBContext : DbContext { +public static class HBObjectGuid { public static readonly Guid NsfwTag = new("EBDAD4F8-455A-4351-8017-1D4854D6FA38"); public static readonly Guid IngestTag = new("EA212801-5BCC-4C0E-814F-FB9D30DB58BC"); + public static readonly Guid AdminUser = new("0623F137-F9D7-456C-A79F-C866B556FBF6"); +} +public class HBContext : DbContext { public DbSet<HBObject> Objects { get; set; } public DbSet<TagDefinition> TagDefinitions { get; set; } public DbSet<Tag> Tags { get; set; } @@ -47,19 +50,20 @@ public class HBContext : DbContext { modelBuilder.Entity<Tag>().ToTable("Tags"); modelBuilder.Entity<Media>().ToTable("Media"); modelBuilder.Entity<UploadedFile>().ToTable("UploadedFiles"); + modelBuilder.Entity<HBPrincipal>().ToTable("SecurityPrincipals"); // Seed internal tag definitions // These should NEVER change modelBuilder.Entity<TagDefinition>().HasData(new TagDefinition[] { new() { ObjectId = (int) HBObjectId.NsfwTag, - Guid = NsfwTag, + Guid = HBObjectGuid.NsfwTag, Source = TagSource.Internal, Name = "nsfw" }, new() { ObjectId = (int) HBObjectId.IngestTag, - Guid = IngestTag, + Guid = HBObjectGuid.IngestTag, Source = TagSource.Internal, Name = "ingest" } @@ -69,7 +73,9 @@ public class HBContext : DbContext { modelBuilder.Entity<User>().HasData(new User[] { new() { ObjectId = (int) HBObjectId.AdminUser, + Guid = HBObjectGuid.AdminUser, Name = "admin", + Sid = new SecurityIdentifier("S-1-5-18"), PasswordHash = UserService.HashPassword("admin") } }); @@ -85,4 +91,10 @@ public class HBContext : DbContext { .WithOne() .HasForeignKey<Media>("CurrentUploadedFileId"); } + + protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) { + configurationBuilder + .Properties<SecurityIdentifier>() + .HaveConversion<SecurityIdentifierConverter>(); + } }
\ No newline at end of file |
