using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace Backend.Data;

public sealed class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<AwardsDbContext>
{
    public AwardsDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<AwardsDbContext>();
        var connectionString = Environment.GetEnvironmentVariable("VTSA_POSTGRES")
            ?? "Host=localhost;Port=5432;Database=vtuber_star_awards;Username=postgres;Password=postgres";

        optionsBuilder.UseNpgsql(connectionString);
        return new AwardsDbContext(optionsBuilder.Options);
    }
}
