using DeepDrftModels.Entities;
using DeepDrftData.Data.Configurations;
using Microsoft.EntityFrameworkCore;

namespace DeepDrftData.Data;

public class DeepDrftContext : DbContext
{
    public DeepDrftContext(DbContextOptions<DeepDrftContext> options) : base(options)
    {
    }

    public DbSet<TrackEntity> Tracks { get; set; }
    public DbSet<ReleaseEntity> Releases { get; set; }
    public DbSet<SessionMetadata> SessionMetadata { get; set; }
    public DbSet<MixMetadata> MixMetadata { get; set; }

    // Phase 16 anonymous telemetry: append-only event logs + incremental play rollup. All SQL — the
    // FileDatabase vault is not involved.
    public DbSet<PlayEvent> PlayEvents { get; set; }
    public DbSet<ShareEvent> ShareEvents { get; set; }
    public DbSet<PlayCounter> PlayCounters { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.ApplyConfiguration(new TrackConfiguration());
        modelBuilder.ApplyConfiguration(new ReleaseConfiguration());
        modelBuilder.ApplyConfiguration(new SessionMetadataConfiguration());
        modelBuilder.ApplyConfiguration(new MixMetadataConfiguration());
        modelBuilder.ApplyConfiguration(new PlayEventConfiguration());
        modelBuilder.ApplyConfiguration(new ShareEventConfiguration());
        modelBuilder.ApplyConfiguration(new PlayCounterConfiguration());
    }
}
