Add Heimdall patron support intake

This commit is contained in:
Meta Vens 2026-06-09 17:16:27 +01:00
commit bb1b1056be
21 changed files with 625 additions and 13 deletions

View file

@ -334,10 +334,17 @@ public sealed class BifrostDbContext(DbContextOptions<BifrostDbContext> options)
modelBuilder.Entity<PatronSupportEvent>(entity =>
{
entity.Property(x => x.Kind).HasConversion<string>();
entity.Property(x => x.Provider).HasConversion<string>();
entity.Property(x => x.Amount).HasPrecision(18, 2);
entity.Property(x => x.ExternalSupportId).HasMaxLength(240);
entity.Property(x => x.ProviderEventId).HasMaxLength(240);
entity.Property(x => x.ProviderPayerId).HasMaxLength(240);
entity.Property(x => x.ProviderSubscriptionId).HasMaxLength(240);
entity.Property(x => x.CurrencyCode).HasMaxLength(12);
entity.HasIndex(x => new { x.UserAccountId, x.Kind, x.IsCurrentRecurringSupport });
entity.HasIndex(x => new { x.Provider, x.ProviderEventId })
.IsUnique()
.HasFilter("\"ProviderEventId\" <> ''");
entity.HasOne(x => x.UserAccount)
.WithMany(x => x.PatronSupportEvents)
.HasForeignKey(x => x.UserAccountId)

View file

@ -0,0 +1,75 @@
using Bifrost.Web.Domain;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bifrost.Web.Data.Migrations
{
[Migration("20260609160000_AddExternalPatronProviderIntake")]
public partial class AddExternalPatronProviderIntake : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Provider",
table: "PatronSupportEvents",
type: "text",
nullable: false,
defaultValue: nameof(ExternalPatronProvider.Manual));
migrationBuilder.AddColumn<string>(
name: "ProviderEventId",
table: "PatronSupportEvents",
type: "character varying(240)",
maxLength: 240,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "ProviderPayerId",
table: "PatronSupportEvents",
type: "character varying(240)",
maxLength: 240,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "ProviderSubscriptionId",
table: "PatronSupportEvents",
type: "character varying(240)",
maxLength: 240,
nullable: false,
defaultValue: "");
migrationBuilder.CreateIndex(
name: "IX_PatronSupportEvents_Provider_ProviderEventId",
table: "PatronSupportEvents",
columns: new[] { "Provider", "ProviderEventId" },
unique: true,
filter: "\"ProviderEventId\" <> ''");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_PatronSupportEvents_Provider_ProviderEventId",
table: "PatronSupportEvents");
migrationBuilder.DropColumn(
name: "Provider",
table: "PatronSupportEvents");
migrationBuilder.DropColumn(
name: "ProviderEventId",
table: "PatronSupportEvents");
migrationBuilder.DropColumn(
name: "ProviderPayerId",
table: "PatronSupportEvents");
migrationBuilder.DropColumn(
name: "ProviderSubscriptionId",
table: "PatronSupportEvents");
}
}
}

View file

@ -500,6 +500,25 @@ namespace Bifrost.Web.Data.Migrations
b.Property<DateTimeOffset>("RecordedAtUtc")
.HasColumnType("timestamp with time zone");
b.Property<string>("Provider")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ProviderEventId")
.IsRequired()
.HasMaxLength(240)
.HasColumnType("character varying(240)");
b.Property<string>("ProviderPayerId")
.IsRequired()
.HasMaxLength(240)
.HasColumnType("character varying(240)");
b.Property<string>("ProviderSubscriptionId")
.IsRequired()
.HasMaxLength(240)
.HasColumnType("character varying(240)");
b.Property<DateTimeOffset>("SupportedAtUtc")
.HasColumnType("timestamp with time zone");
@ -512,6 +531,10 @@ namespace Bifrost.Web.Data.Migrations
b.HasIndex("UserAccountId", "Kind", "IsCurrentRecurringSupport");
b.HasIndex("Provider", "ProviderEventId")
.IsUnique()
.HasFilter("\"ProviderEventId\" <> ''");
b.ToTable("PatronSupportEvents");
});