using Microsoft.EntityFrameworkCore;
using Solar.Api.Entities;

namespace Solar.Api
{
    public partial class DatabaseContext : DbContext
    {
        public DatabaseContext()
        {
        }

        public DatabaseContext(DbContextOptions<DatabaseContext> options)
            : base(options)
        {
        }

        public virtual DbSet<EnvoyLog> EnvoyLogs { get; set; } = null!;
        public virtual DbSet<ZeverLog> ZeverLogs { get; set; } = null!;
        public virtual DbSet<ZeverSummary> ZeverSummaries { get; set; } = null!;

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<EnvoyLog>(entity =>
            {
                entity.HasIndex(e => e.Date, "idx_EnvoyLogs_Date");

                entity.HasIndex(e => e.TimeUtc, "idx_EnvoyLogs_TimeUtc");

                entity.HasIndex(e => e.TotalWatts, "idx_EnvoyLogs_TotalWatts");

                entity.Property(e => e.TotalWatts).HasColumnType("BIGINT");
            });

            modelBuilder.Entity<ZeverLog>(entity =>
            {
                entity.HasIndex(e => e.Date, "idx_ZeverLogs_Date");

                entity.HasIndex(e => e.TimeUtc, "idx_ZeverLogs_TimeUtc");

                entity.HasIndex(e => e.TotalWatts, "idx_ZeverLogs_TotalWatts");

                entity.Property(e => e.TotalWatts).HasColumnType("BIGINT");
            });

            modelBuilder.Entity<ZeverSummary>(entity =>
            {
                entity.ToTable("ZeverSummary");

                entity.HasIndex(e => e.Date, "IX_ZeverSummary_Date")
                    .IsUnique();

                entity.HasIndex(e => e.Date, "idx_ZeverSummary_Date")
                    .IsUnique();

                entity.Property(e => e.TotalWatts).HasColumnType("BIGINT");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
