diff options
| author | JPVenson <github@jpb.email> | 2025-01-27 17:43:34 +0000 |
|---|---|---|
| committer | JPVenson <github@jpb.email> | 2025-01-27 17:43:34 +0000 |
| commit | 433640d98534667602bfaac08ce7cdb600a8377b (patch) | |
| tree | 39377893e80ba8d2708a295bbbe11cd9834c3094 /Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs | |
| parent | 844646e2fe6d726edc8e086cc465396303d24f29 (diff) | |
Added pgsql support for jellyfin 🎉
Diffstat (limited to 'Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs')
| -rw-r--r-- | Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs b/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs new file mode 100644 index 0000000000..8f5e2e82b2 --- /dev/null +++ b/Jellyfin.Database/Jellyfin.Database.Providers.PgSql/Migrations/PgSqlDesignTimeJellyfinDbFactory.cs @@ -0,0 +1,26 @@ +using Jellyfin.Database.Providers.SqLite; +using Jellyfin.Server.Implementations; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Logging.Abstractions; + +namespace Jellyfin.Database.Providers.PgSql +{ + /// <summary> + /// The design time factory for <see cref="JellyfinDbContext"/>. + /// This is only used for the creation of migrations and not during runtime. + /// </summary> + internal sealed class PgSqlDesignTimeJellyfinDbFactory : IDesignTimeDbContextFactory<JellyfinDbContext> + { + public JellyfinDbContext CreateDbContext(string[] args) + { + var optionsBuilder = new DbContextOptionsBuilder<JellyfinDbContext>(); + optionsBuilder.UseNpgsql(f => f.MigrationsAssembly(GetType().Assembly)); + + return new JellyfinDbContext( + optionsBuilder.Options, + NullLogger<JellyfinDbContext>.Instance, + new SqliteDatabaseProvider(null!, NullLogger<SqliteDatabaseProvider>.Instance)); + } + } +} |
