This commit is contained in:
6d486f49
2026-08-17 00:45:08 -04:00
parent 3a2f112a73
commit 1d6207fbfe
154 changed files with 126007 additions and 47385 deletions
+33
View File
@@ -0,0 +1,33 @@
using API.Models;
using Microsoft.EntityFrameworkCore;
using Model;
namespace API.Data;
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
public DbSet<User> Users { get; set; } = default!;
public DbSet<CardNote> CardNotes { get; set; } = default!;
public DbSet<UserDeck> UserDecks { get; set; } = default!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<User>(b => { b.HasKey(u => u.Username); });
modelBuilder.Entity<CardNote>(b => { b.HasKey(n => new { n.Username, n.CardName }); });
modelBuilder.Entity<UserDeck>(b =>
{
b.HasKey(d => d.Id);
if (Database.IsNpgsql())
{
b.Property(d => d.Cards).HasColumnType("jsonb");
b.Property(d => d.Divers).HasColumnType("jsonb");
}
});
}
}