Introduce Family entity and bootstrap default family on startup

Foundation for the multi-tenant migration: adds the Family table with a
unique InviteCode, and a startup hook that bootstraps a single default
family from the FamilyCode config when the table is empty. No behavior
change yet — the table exists and is seeded but nothing reads it.

Also fixes the backend test command in CLAUDE.md: dotnet test on the
.NET 10 SDK with MTP rejects the --solution switch and positional
project args, so we now use Push-Location + --project.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Josh Rogers
2026-05-07 23:00:00 -05:00
parent 6f71f8c2d6
commit 7c1cfd62e6
7 changed files with 443 additions and 5 deletions
@@ -5,6 +5,7 @@ namespace YesChef.Api.Data;
public class YesChefDb(DbContextOptions<YesChefDb> options) : DbContext(options)
{
public DbSet<Family> Families => Set<Family>();
public DbSet<User> Users => Set<User>();
public DbSet<Store> Stores => Set<Store>();
public DbSet<ShoppingList> ShoppingLists => Set<ShoppingList>();
@@ -14,6 +15,13 @@ public class YesChefDb(DbContextOptions<YesChefDb> options) : DbContext(options)
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Family>(e =>
{
e.HasIndex(f => f.InviteCode).IsUnique();
e.Property(f => f.Name).HasMaxLength(100);
e.Property(f => f.InviteCode).HasMaxLength(100);
});
modelBuilder.Entity<User>(e =>
{
e.HasIndex(u => u.Name).IsUnique();