Switched to database scheme seperation from MoonCores SingleDb. Updated mooncore versions. Updating to correct Async naming
This commit is contained in:
@@ -1,34 +1,47 @@
|
||||
using Hangfire.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MoonCore.Extended.SingleDb;
|
||||
using Moonlight.ApiServer.Configuration;
|
||||
using Moonlight.ApiServer.Database.Entities;
|
||||
using Moonlight.ApiServer.Models;
|
||||
|
||||
namespace Moonlight.ApiServer.Database;
|
||||
|
||||
public class CoreDataContext : DatabaseContext
|
||||
public class CoreDataContext : DbContext
|
||||
{
|
||||
public override string Prefix { get; } = "Core";
|
||||
|
||||
private readonly AppConfiguration Configuration;
|
||||
|
||||
public DbSet<User> Users { get; set; }
|
||||
public DbSet<ApiKey> ApiKeys { get; set; }
|
||||
public DbSet<Theme> Themes { get; set; }
|
||||
|
||||
public CoreDataContext(AppConfiguration configuration)
|
||||
{
|
||||
Options = new()
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if(optionsBuilder.IsConfigured)
|
||||
return;
|
||||
|
||||
var database = Configuration.Database;
|
||||
|
||||
var connectionString = $"Host={database.Host};" +
|
||||
$"Port={database.Port};" +
|
||||
$"Database={database.Database};" +
|
||||
$"Username={database.Username};" +
|
||||
$"Password={database.Password}";
|
||||
|
||||
optionsBuilder.UseNpgsql(connectionString, builder =>
|
||||
{
|
||||
Host = configuration.Database.Host,
|
||||
Port = configuration.Database.Port,
|
||||
Username = configuration.Database.Username,
|
||||
Password = configuration.Database.Password,
|
||||
Database = configuration.Database.Database
|
||||
};
|
||||
builder.MigrationsHistoryTable("MigrationsHistory", "core");
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Model.SetDefaultSchema("core");
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
modelBuilder.OnHangfireModelCreating();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user