2020-11-27 22:52:52 -05:00
|
|
|
|
using System;
|
2021-03-22 12:09:25 -04:00
|
|
|
|
using Data.Context;
|
|
|
|
|
using Data.Extensions;
|
2020-11-27 22:52:52 -05:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
2021-03-22 12:09:25 -04:00
|
|
|
|
namespace Data.MigrationContext
|
2020-11-27 22:52:52 -05:00
|
|
|
|
{
|
|
|
|
|
public class PostgresqlDatabaseContext : DatabaseContext
|
|
|
|
|
{
|
|
|
|
|
public PostgresqlDatabaseContext()
|
|
|
|
|
{
|
2021-03-22 12:09:25 -04:00
|
|
|
|
if (!MigrationExtensions.IsMigration)
|
2020-11-27 22:52:52 -05:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-22 12:09:25 -04:00
|
|
|
|
|
2020-11-29 17:01:52 -05:00
|
|
|
|
public PostgresqlDatabaseContext(DbContextOptions options) : base(options)
|
2020-11-27 22:52:52 -05:00
|
|
|
|
{
|
|
|
|
|
}
|
2021-03-22 12:09:25 -04:00
|
|
|
|
|
2020-11-27 22:52:52 -05:00
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
2021-03-22 12:09:25 -04:00
|
|
|
|
if (MigrationExtensions.IsMigration)
|
2020-11-27 22:52:52 -05:00
|
|
|
|
{
|
|
|
|
|
optionsBuilder.UseNpgsql(
|
2021-03-22 12:09:25 -04:00
|
|
|
|
"Host=127.0.0.1;Database=IW4MAdmin_Migration;Username=postgres;Password=password;",
|
2022-01-28 15:33:08 -05:00
|
|
|
|
options => options.SetPostgresVersion(new Version("12.9")))
|
2020-11-27 22:52:52 -05:00
|
|
|
|
.EnableDetailedErrors(true)
|
|
|
|
|
.EnableSensitiveDataLogging(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-28 15:33:08 -05:00
|
|
|
|
}
|