From 66eb012e4a8903cb976a653fdf830768f86f0d85 Mon Sep 17 00:00:00 2001 From: Ske Date: Tue, 7 Jan 2020 16:31:46 +0100 Subject: [PATCH] Fix database errors on first startup --- PluralKit.Core/SchemaService.cs | 5 +++++ PluralKit.Core/Utils.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/PluralKit.Core/SchemaService.cs b/PluralKit.Core/SchemaService.cs index fa3b1c78..ba2f8bf5 100644 --- a/PluralKit.Core/SchemaService.cs +++ b/PluralKit.Core/SchemaService.cs @@ -57,6 +57,11 @@ namespace PluralKit { _logger.Information("Current schema version is {CurrentVersion}, applying migration {MigrationId}", currentVersion, migrationId); await conn.ExecuteAsync(migrationQuery, transaction: tx); tx.Commit(); + + // If the above migration creates new enum/composite types, we must tell Npgsql to reload the internal type caches + // This will propagate to every other connection as well, since it marks the global type mapper collection dirty. + // TODO: find a way to get around the cast to our internal tracker wrapper... this could break if that ever changes + ((PerformanceTrackingConnection) conn)._impl.ReloadTypes(); } } } \ No newline at end of file diff --git a/PluralKit.Core/Utils.cs b/PluralKit.Core/Utils.cs index 300f27bc..5b1126c8 100644 --- a/PluralKit.Core/Utils.cs +++ b/PluralKit.Core/Utils.cs @@ -451,7 +451,7 @@ namespace PluralKit public class PerformanceTrackingConnection: IDbConnection { // Simple delegation of everything. - private NpgsqlConnection _impl; + internal NpgsqlConnection _impl; private DbConnectionCountHolder _countHolder; private ILogger _logger;