using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using isnd.Data;
using isnd.Data.ApiKeys;
using isnd.Data.Catalog;
using isnd.Data.Historic;

namespace isnd.Data
{
    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
            : base(options)
        {
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<PackageVersion>().HasKey(v => new
            { 
                v.PackageId,
                v.FullString,
                v.Type
            });
            modelBuilder.Entity<PackageVersionCommit>().HasKey
            (c => new { c.CommitId, c.PackageId, c.FullString, c.PackageType });

        }
        public DbSet<ApiKey> ApiKeys { get; set; }
        public DbSet<Package> Packages { get; set; }
        public DbSet<PackageVersion> PackageVersions { get; set; }
        public DbSet<Commit> Commits { get; set; }

        public DbSet<PackageVersionCommit> PackageVersionCommmit { get; set; }
    }
}
