From 50d617ec672618f86ff735d3d2c47d0245b1ab4d Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Tue, 1 Apr 2025 12:41:07 -0400 Subject: [PATCH] Add missing migration --- .../Data/MembershipDbContextInitializer.cs | 4 +- ...0250401042836_StripeIdNullable.Designer.cs | 291 ++++++++++++++++++ .../20250401042836_StripeIdNullable.cs | 38 +++ 3 files changed, 330 insertions(+), 3 deletions(-) create mode 100644 backend/src/Web/Features/Memberships/Data/Migrations/20250401042836_StripeIdNullable.Designer.cs create mode 100644 backend/src/Web/Features/Memberships/Data/Migrations/20250401042836_StripeIdNullable.cs diff --git a/backend/src/Web/Features/Memberships/Data/MembershipDbContextInitializer.cs b/backend/src/Web/Features/Memberships/Data/MembershipDbContextInitializer.cs index 80d3937..3ddaeba 100644 --- a/backend/src/Web/Features/Memberships/Data/MembershipDbContextInitializer.cs +++ b/backend/src/Web/Features/Memberships/Data/MembershipDbContextInitializer.cs @@ -1,5 +1,3 @@ -using Hutopy.Web.Features.Contents.Data; - namespace Hutopy.Web.Features.Memberships.Data; public static class InitializerExtensions @@ -17,7 +15,7 @@ public static class InitializerExtensions public class MembershipDbContextInitializer( ILogger logger, MembershipDbContext context - ) +) { public async Task InitialiseAsync() { diff --git a/backend/src/Web/Features/Memberships/Data/Migrations/20250401042836_StripeIdNullable.Designer.cs b/backend/src/Web/Features/Memberships/Data/Migrations/20250401042836_StripeIdNullable.Designer.cs new file mode 100644 index 0000000..ab06aa1 --- /dev/null +++ b/backend/src/Web/Features/Memberships/Data/Migrations/20250401042836_StripeIdNullable.Designer.cs @@ -0,0 +1,291 @@ +// +using System; +using Hutopy.Web.Features.Memberships.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 Hutopy.Web.Features.Memberships.Data.Migrations +{ + [DbContext(typeof(MembershipDbContext))] + [Migration("20250401042836_StripeIdNullable")] + partial class StripeIdNullable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Membership") + .HasAnnotation("ProductVersion", "9.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Creator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PortraitUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("StripeAccountId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Creators", "Membership"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Subscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("CreatorId") + .HasColumnType("uuid"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone"); + + b.Property("StripeSessionId") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("StripeSubscriptionId") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("TierId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CreatorId"); + + b.HasIndex("TierId"); + + b.ToTable("Subscriptions", "Membership"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Tier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("CreatorId") + .HasColumnType("uuid"); + + b.Property("CurrencyCode") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(4096) + .HasColumnType("character varying(4096)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.Property("StripePriceId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("StripeProductId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.HasKey("Id"); + + b.HasIndex("CreatorId"); + + b.ToTable("Tiers", "Membership"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Tip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("CreatorId") + .HasColumnType("uuid"); + + b.Property("CreatorName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Currency") + .IsRequired() + .HasColumnType("text"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("StripeSessionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("TipperId") + .HasColumnType("uuid"); + + b.Property("TipperName") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("TransactionId"); + + b.ToTable("Tips", "Membership"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Transaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Currency") + .IsRequired() + .HasColumnType("text"); + + b.Property("StripeInvoiceUrl") + .HasColumnType("text"); + + b.Property("SubscriptionId") + .HasColumnType("uuid"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("SubscriptionId"); + + b.ToTable("Transactions", "Membership"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Subscription", b => + { + b.HasOne("Hutopy.Web.Features.Memberships.Data.Creator", "Creator") + .WithMany() + .HasForeignKey("CreatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hutopy.Web.Features.Memberships.Data.Tier", "Tier") + .WithMany("Subscriptions") + .HasForeignKey("TierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + + b.Navigation("Tier"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Tier", b => + { + b.HasOne("Hutopy.Web.Features.Memberships.Data.Creator", "Creator") + .WithMany() + .HasForeignKey("CreatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Tip", b => + { + b.HasOne("Hutopy.Web.Features.Memberships.Data.Transaction", "Transaction") + .WithMany() + .HasForeignKey("TransactionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Transaction"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Transaction", b => + { + b.HasOne("Hutopy.Web.Features.Memberships.Data.Subscription", null) + .WithMany("Transactions") + .HasForeignKey("SubscriptionId"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Subscription", b => + { + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Memberships.Data.Tier", b => + { + b.Navigation("Subscriptions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/src/Web/Features/Memberships/Data/Migrations/20250401042836_StripeIdNullable.cs b/backend/src/Web/Features/Memberships/Data/Migrations/20250401042836_StripeIdNullable.cs new file mode 100644 index 0000000..c517414 --- /dev/null +++ b/backend/src/Web/Features/Memberships/Data/Migrations/20250401042836_StripeIdNullable.cs @@ -0,0 +1,38 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hutopy.Web.Features.Memberships.Data.Migrations +{ + /// + public partial class StripeIdNullable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "StripeAccountId", + schema: "Membership", + table: "Creators", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "StripeAccountId", + schema: "Membership", + table: "Creators", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + } + } +}