fix: don't specify duplicate key_roles in guild repository, let PK API service read strings as numbers
This commit is contained in:
parent
ff92c5f335
commit
56af787e57
3 changed files with 7 additions and 3 deletions
|
|
@ -65,9 +65,11 @@ public class DatabaseMigrator(ILogger logger, IClock clock, DatabaseConnection c
|
||||||
await tx.CommitAsync();
|
await tx.CommitAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ExecuteMigration(DbTransaction tx, string migrationName)
|
private async Task ExecuteMigration(DbTransaction tx, string migrationName, bool up = true)
|
||||||
{
|
{
|
||||||
var query = await GetResource($"{RootPath}.Migrations.{migrationName}.up.sql");
|
var query = await GetResource(
|
||||||
|
$"{RootPath}.Migrations.{migrationName}.{(up ? "up" : "down")}.sql"
|
||||||
|
);
|
||||||
|
|
||||||
// Run the migration
|
// Run the migration
|
||||||
await conn.ExecuteAsync(query, transaction: tx);
|
await conn.ExecuteAsync(query, transaction: tx);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public class GuildRepository(ILogger logger, DatabaseConnection conn)
|
||||||
public async Task AddGuildAsync(ulong id) =>
|
public async Task AddGuildAsync(ulong id) =>
|
||||||
await conn.ExecuteAsync(
|
await conn.ExecuteAsync(
|
||||||
"""
|
"""
|
||||||
insert into guilds (id, key_roles, banned_systems, key_roles, channels)
|
insert into guilds (id, key_roles, banned_systems, channels)
|
||||||
values (@Id, array[]::bigint[], array[]::text[], array[]::bigint[], @Channels)
|
values (@Id, array[]::bigint[], array[]::text[], array[]::bigint[], @Channels)
|
||||||
on conflict do nothing
|
on conflict do nothing
|
||||||
""",
|
""",
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading.RateLimiting;
|
using System.Threading.RateLimiting;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using NodaTime;
|
using NodaTime;
|
||||||
|
|
@ -34,6 +35,7 @@ public class PluralkitApiService(ILogger logger)
|
||||||
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
|
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||||
|
NumberHandling = JsonNumberHandling.AllowReadingFromString,
|
||||||
}.ConfigureForNodaTime(
|
}.ConfigureForNodaTime(
|
||||||
new NodaJsonSettings
|
new NodaJsonSettings
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue