using Backend.Domain; using Microsoft.EntityFrameworkCore; namespace Backend.Data; public sealed class AwardsDbContext(DbContextOptions options) : DbContext(options) { public DbSet Seasons => Set(); public DbSet Categories => Set(); public DbSet Candidates => Set(); public DbSet Results => Set(); public DbSet Nominations => Set(); public DbSet VoteBallots => Set(); public DbSet VoteEntries => Set(); public DbSet UserSessions => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.HasIndex(item => item.Year).IsUnique(); entity.Property(item => item.Name).HasMaxLength(160); entity.Property(item => item.CurrentPhase).HasMaxLength(60); }); modelBuilder.Entity(entity => { entity.HasIndex(item => new { item.SeasonId, item.Slug }).IsUnique(); entity.Property(item => item.GroupName).HasMaxLength(80); entity.Property(item => item.Name).HasMaxLength(120); entity.Property(item => item.Description).HasMaxLength(400); }); modelBuilder.Entity(entity => { entity.Property(item => item.DisplayName).HasMaxLength(120); entity.Property(item => item.ChannelSlug).HasMaxLength(120); entity.Property(item => item.Platform).HasMaxLength(40); }); modelBuilder.Entity(entity => { entity.Property(item => item.SubmittedByTwitchId).HasMaxLength(120); entity.Property(item => item.CandidateText).HasMaxLength(120); }); modelBuilder.Entity(entity => { entity.Property(item => item.SubmittedByTwitchId).HasMaxLength(120); entity.Property(item => item.Status).HasMaxLength(30); }); modelBuilder.Entity(entity => { entity.Property(item => item.CategoryName).HasMaxLength(120); }); modelBuilder.Entity(entity => { entity.HasIndex(item => item.SessionToken).IsUnique(); entity.Property(item => item.SessionToken).HasMaxLength(120); entity.Property(item => item.TwitchUserId).HasMaxLength(120); entity.Property(item => item.DisplayName).HasMaxLength(120); entity.Property(item => item.Role).HasMaxLength(40); }); SeedData.Apply(modelBuilder); } }