using Microsoft.EntityFrameworkCore;
using ColaFlow.Modules.IssueManagement.Domain.Entities;
using System.Reflection;

namespace ColaFlow.Modules.IssueManagement.Infrastructure.Persistence;

/// <summary>
/// DbContext for IssueManagement module
/// </summary>
public sealed class IssueManagementDbContext : DbContext
{
    public DbSet<Issue> Issues => Set<Issue>();

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

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

        // Apply all entity configurations from this assembly
        modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());

        // Global Query Filter for Multi-Tenancy
        // This will be handled by TenantId in queries
        // Note: We don't apply global filter here to allow flexibility
        // Tenant isolation is enforced at repository level
    }
}
