72 lines
2.8 KiB
C#
72 lines
2.8 KiB
C#
using Aberwyn.Models;
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Reflection.Emit;
|
|
|
|
namespace Aberwyn.Data
|
|
{
|
|
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
|
{
|
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
{
|
|
base.OnModelCreating(builder);
|
|
builder.Entity<TorrentItem>()
|
|
.HasIndex(t => t.InfoHash)
|
|
.IsUnique();
|
|
|
|
builder.Entity<TorrentItem>()
|
|
.Property(t => t.Status)
|
|
.HasConversion<string>();
|
|
builder.Entity<WeeklyMenu>().ToTable("WeeklyMenu");
|
|
builder.Entity<MealCategory>().HasData(
|
|
new MealCategory
|
|
{
|
|
Id = 1,
|
|
Name = "Pizza",
|
|
Slug = "pizza",
|
|
Icon = "🍕",
|
|
Color = "#f97316",
|
|
IsActive = true,
|
|
DisplayOrder = 1
|
|
}
|
|
);
|
|
builder.Entity<TorrentItem>()
|
|
.OwnsOne(t => t.Metadata);
|
|
}
|
|
|
|
|
|
public DbSet<DoughPlan> DoughPlans { get; set; }
|
|
|
|
public DbSet<BudgetPeriod> BudgetPeriods { get; set; }
|
|
public DbSet<BudgetCategory> BudgetCategories { get; set; }
|
|
public DbSet<BudgetItem> BudgetItems { get; set; }
|
|
public DbSet<PushSubscriber> PushSubscribers { get; set; }
|
|
public DbSet<PizzaOrder> PizzaOrders { get; set; }
|
|
public DbSet<AppSetting> AppSettings { get; set; }
|
|
public DbSet<TodoTask> TodoTasks { get; set; }
|
|
public DbSet<BudgetItemDefinition> BudgetItemDefinitions { get; set; }
|
|
public DbSet<BudgetCategoryDefinition> BudgetCategoryDefinitions { get; set; }
|
|
public DbSet<Meal> Meals { get; set; }
|
|
public DbSet<WeeklyMenu> WeeklyMenus { get; set; }
|
|
public DbSet<Ingredient> Ingredients { get; set; }
|
|
public DbSet<UserPreferences> UserPreferences { get; set; }
|
|
public DbSet<StoredPushSubscription> PushSubscriptions { get; set; }
|
|
public DbSet<MealCategory> MealCategories { get; set; }
|
|
public DbSet<RecipeLabEntry> RecipeLabEntries { get; set; }
|
|
public DbSet<RecipeLabVersion> RecipeLabVersions { get; set; }
|
|
public DbSet<LabIngredient> LabIngredients { get; set; }
|
|
public DbSet<LabVersionIngredient> LabVersionIngredients { get; set; }
|
|
public DbSet<MealRating> MealRatings { get; set; }
|
|
public DbSet<TorrentItem> TorrentItems { get; set; }
|
|
public DbSet<RssFeed> RssFeeds { get; set; }
|
|
public DbSet<DownloadRule> DownloadRules { get; set; }
|
|
public DbSet<UserTorrentSeen> UserTorrentSeen { get; set; }
|
|
|
|
}
|
|
}
|