Removed pgsql from refactor

This commit is contained in:
JPVenson
2025-02-19 18:21:23 +00:00
parent 8b07c1f53d
commit ddc20b74bf
12 changed files with 1 additions and 6226 deletions

View File

@@ -1,50 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<!-- Code Analyzers -->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="IDisposableAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SerilogAnalyzer" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\SharedVersion.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Jellyfin.Data\Jellyfin.Data.csproj" />
<ProjectReference Include="..\..\MediaBrowser.Controller\MediaBrowser.Controller.csproj" />
<ProjectReference Include="..\..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,55 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jellyfin.Database.Providers.PgSql.Migrations
{
/// <inheritdoc />
public partial class MakeStartEndDateNullable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "StartDate",
table: "BaseItems",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<DateTime>(
name: "EndDate",
table: "BaseItems",
type: "timestamp with time zone",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "StartDate",
table: "BaseItems",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "EndDate",
table: "BaseItems",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldNullable: true);
}
}
}

View File

@@ -1,25 +0,0 @@
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 PgSqlDatabaseProvider(null!, NullLogger<PgSqlDatabaseProvider>.Instance));
}
}
}

View File

@@ -1,77 +0,0 @@
using System;
using System.Diagnostics;
using System.Reflection;
using Jellyfin.Server.Implementations;
using Jellyfin.Server.Implementations.DatabaseConfiguration;
using MediaBrowser.Common.Configuration;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Npgsql;
namespace Jellyfin.Database.Providers.PgSql;
/// <summary>
/// Configures jellyfin to use an Postgres database.
/// </summary>
[JellyfinDatabaseProviderKey("Jellyfin-PgSql")]
public sealed class PgSqlDatabaseProvider : IJellyfinDatabaseProvider
{
private readonly IConfigurationManager _configurationManager;
private readonly ILogger<PgSqlDatabaseProvider> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="PgSqlDatabaseProvider"/> class.
/// </summary>
/// <param name="configurationManager">Configuration manager to get PgSQL connection data.</param>
/// <param name="logger">A logger.</param>
public PgSqlDatabaseProvider(IConfigurationManager configurationManager, ILogger<PgSqlDatabaseProvider> logger)
{
_configurationManager = configurationManager;
_logger = logger;
}
/// <inheritdoc/>
public IDbContextFactory<JellyfinDbContext>? DbContextFactory { get; set; }
/// <inheritdoc/>
public void Initialise(DbContextOptionsBuilder options)
{
var dbSettings = _configurationManager.GetConfiguration<DatabaseConfigurationOptions>("database");
if (dbSettings.PostgreSql is null)
{
throw new InvalidOperationException("Selected PgSQL as database provider but did not provide required configuration. Please see docs.");
}
var connectionBuilder = new NpgsqlConnectionStringBuilder();
connectionBuilder.ApplicationName = $"jellyfin+{FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()!.Location).FileVersion}";
connectionBuilder.CommandTimeout = dbSettings.PostgreSql.Timeout;
connectionBuilder.Database = dbSettings.PostgreSql.DatabaseName;
connectionBuilder.Username = dbSettings.PostgreSql.Username;
connectionBuilder.Password = dbSettings.PostgreSql.Password;
connectionBuilder.Host = dbSettings.PostgreSql.ServerName;
connectionBuilder.Port = dbSettings.PostgreSql.Port;
var connectionString = connectionBuilder.ToString();
options
.UseNpgsql(connectionString, pgSqlOptions => pgSqlOptions.MigrationsAssembly(GetType().Assembly));
}
/// <inheritdoc/>
public Task RunScheduledOptimisation(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
/// <inheritdoc/>
public void OnModelCreating(ModelBuilder modelBuilder)
{
}
/// <inheritdoc/>
public Task RunShutdownTask(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}

View File

@@ -1,23 +0,0 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Jellyfin.Database.Providers.PgSql")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Jellyfin Project")]
[assembly: AssemblyProduct("Jellyfin Server")]
[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: InternalsVisibleTo("Jellyfin.Server.Implementations.Tests")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]