Add PostgreSQL EF Core design-time factory and InitialPostgreSql migration (#8)
* Initial plan * Add PostgreSQL design-time factory and initial migration for all 29 DbSets Co-authored-by: ZoltyMat <177592743+ZoltyMat@users.noreply.github.com> * Remove accidentally committed build artifacts from PostgreSQL provider Co-authored-by: ZoltyMat <177592743+ZoltyMat@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ZoltyMat <177592743+ZoltyMat@users.noreply.github.com>
This commit is contained in:
+1690
File diff suppressed because it is too large
Load Diff
+1146
File diff suppressed because it is too large
Load Diff
+1687
File diff suppressed because it is too large
Load Diff
+32
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Jellyfin.Database.Implementations;
|
||||
using Jellyfin.Database.Implementations.Locking;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace Jellyfin.Database.Providers.PostgreSQL;
|
||||
|
||||
/// <summary>
|
||||
/// The design time factory for <see cref="JellyfinDbContext"/> using PostgreSQL.
|
||||
/// This is only used for the creation of migrations and not during runtime.
|
||||
/// </summary>
|
||||
internal sealed class PostgreSqlDesignTimeJellyfinDbFactory : IDesignTimeDbContextFactory<JellyfinDbContext>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public JellyfinDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var connectionString =
|
||||
Environment.GetEnvironmentVariable("POSTGRES_CONNECTION_STRING")
|
||||
?? "Host=localhost;Database=jellyfin;Username=postgres;Password=postgres";
|
||||
|
||||
var optionsBuilder = new DbContextOptionsBuilder<JellyfinDbContext>();
|
||||
optionsBuilder.UseNpgsql(connectionString, o => o.MigrationsAssembly(GetType().Assembly));
|
||||
|
||||
return new JellyfinDbContext(
|
||||
optionsBuilder.Options,
|
||||
NullLogger<JellyfinDbContext>.Instance,
|
||||
new PostgreSqlDatabaseProvider(),
|
||||
new NoLockBehavior(NullLogger<NoLockBehavior>.Instance));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user