From 3f18e5476a5a2b7f5d74de20400276f419258b51 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 15 Mar 2023 09:31:19 +0900 Subject: [PATCH] Error when indexing invoices with some field that are too long (Fix #4771) --- .../Migrations/20230315062447_fixmaxlength.cs | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 BTCPayServer.Data/Migrations/20230315062447_fixmaxlength.cs diff --git a/BTCPayServer.Data/Migrations/20230315062447_fixmaxlength.cs b/BTCPayServer.Data/Migrations/20230315062447_fixmaxlength.cs new file mode 100644 index 000000000..0ab9f3c88 --- /dev/null +++ b/BTCPayServer.Data/Migrations/20230315062447_fixmaxlength.cs @@ -0,0 +1,31 @@ +using System; +using BTCPayServer.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace BTCPayServer.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20230315062447_fixmaxlength")] + public partial class fixmaxlength : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + if (migrationBuilder.IsNpgsql()) + { + migrationBuilder.Sql("ALTER TABLE \"InvoiceSearches\" ALTER COLUMN \"Value\" TYPE TEXT USING \"Value\"::TEXT;"); + migrationBuilder.Sql("ALTER TABLE \"Invoices\" ALTER COLUMN \"OrderId\" TYPE TEXT USING \"OrderId\"::TEXT;"); + } + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + // Not supported + } + } +}