2025-07-19 04:02:09 -05:00
|
|
|
using FreeTubeSync.Model;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace FreeTubeSync.Database;
|
|
|
|
|
|
|
|
|
|
public class DataContext : DbContext
|
|
|
|
|
{
|
|
|
|
|
public DataContext(DbContextOptions<DataContext> options) : base(options)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
|
|
|
|
optionsBuilder.UseSqlite("Data Source=FreeTubeSync.db");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<Setting>()
|
|
|
|
|
.ToTable("Settings")
|
|
|
|
|
.HasKey(s => s._id);
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Setting>()
|
|
|
|
|
.Property(s => s.ValueJson)
|
|
|
|
|
.HasColumnName("Value")
|
|
|
|
|
.IsRequired();
|
2025-07-19 12:38:36 -05:00
|
|
|
|
|
|
|
|
modelBuilder.Entity<Profile>()
|
|
|
|
|
.ToTable("Profiles")
|
|
|
|
|
.HasKey(s => s._id);
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Profile>()
|
|
|
|
|
.Navigation(e => e.subscriptions).AutoInclude();
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Playlist>()
|
|
|
|
|
.ToTable("Playlists")
|
|
|
|
|
.HasKey(s => s._id);
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Playlist>()
|
|
|
|
|
.Navigation(e => e.videos).AutoInclude();
|
2025-07-19 04:02:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DbSet<History> Histories { get; set; }
|
|
|
|
|
public DbSet<Playlist> Playlists { get; set; }
|
|
|
|
|
public DbSet<Profile> Profiles { get; set; }
|
|
|
|
|
public DbSet<SearchHistory> SearchHistories { get; set; }
|
|
|
|
|
public DbSet<Setting> Settings { get; set; }
|
|
|
|
|
public DbSet<Subscription> Subscriptions { get; set; }
|
|
|
|
|
public DbSet<Video> Videos { get; set; }
|
|
|
|
|
}
|