From 114a10416a573599f534baf043618b632ff36c45 Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Sun, 20 Oct 2024 16:49:59 -0400 Subject: [PATCH] Fix runtime --- src/Web/Common/BlobStorage/ContentTypes.cs | 16 +- src/Web/Features/Contents/Data/Content.cs | 2 +- .../Contents/Data/ContentDbContext.cs | 11 - src/Web/Features/Contents/Data/Follower.cs | 9 - .../20240806065219_Initial.Designer.cs | 258 -------------- .../20240816212531_AddsSoftDelete.Designer.cs | 264 -------------- .../20240816212531_AddsSoftDelete.cs | 43 --- ...824185551_AddReactionToContent.Designer.cs | 296 ---------------- .../20240824185551_AddReactionToContent.cs | 48 --- ...9045548_UseMeterialColorSchema.Designer.cs | 320 ----------------- .../20240919045548_UseMeterialColorSchema.cs | 144 -------- ...919051151_NoMoreOptionalColors.Designer.cs | 330 ------------------ .../20240919051151_NoMoreOptionalColors.cs | 258 -------------- ...22064815_RemovesAboutAddsTitle.Designer.cs | 310 ---------------- .../20240922064815_RemovesAboutAddsTitle.cs | 43 --- ...241011103653_FromSubscribersToFollowers.cs | 81 ----- ....cs => 20241020202641_Initial.Designer.cs} | 43 +-- ...9_Initial.cs => 20241020202641_Initial.cs} | 54 +-- .../ContentDbContextModelSnapshot.cs | 38 +- .../Handlers/CreateContentFromHtml.cs | 25 +- .../Contents/Handlers/FollowCreator.cs | 55 --- .../Contents/Handlers/GetCreatorByAlias.cs | 7 +- .../Contents/Handlers/GetFollowedCreators.cs | 35 -- .../Features/Contents/Handlers/InsertImage.cs | 10 +- .../Contents/Handlers/Models/CreatorModel.cs | 3 +- .../Contents/Handlers/UnfollowCreator.cs | 45 --- .../Handlers/ConfigureStripeAccount.cs | 52 +++ src/Web/TestDataSeeder.cs | 4 - src/Web/Web.csproj | 6 + 29 files changed, 133 insertions(+), 2677 deletions(-) delete mode 100644 src/Web/Features/Contents/Data/Follower.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240806065219_Initial.Designer.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240816212531_AddsSoftDelete.Designer.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240816212531_AddsSoftDelete.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240824185551_AddReactionToContent.Designer.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240824185551_AddReactionToContent.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240919045548_UseMeterialColorSchema.Designer.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240919045548_UseMeterialColorSchema.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240919051151_NoMoreOptionalColors.Designer.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240919051151_NoMoreOptionalColors.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240922064815_RemovesAboutAddsTitle.Designer.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20240922064815_RemovesAboutAddsTitle.cs delete mode 100644 src/Web/Features/Contents/Data/Migrations/20241011103653_FromSubscribersToFollowers.cs rename src/Web/Features/Contents/Data/Migrations/{20241011103653_FromSubscribersToFollowers.Designer.cs => 20241020202641_Initial.Designer.cs} (89%) rename src/Web/Features/Contents/Data/Migrations/{20240806065219_Initial.cs => 20241020202641_Initial.cs} (74%) delete mode 100644 src/Web/Features/Contents/Handlers/FollowCreator.cs delete mode 100644 src/Web/Features/Contents/Handlers/GetFollowedCreators.cs delete mode 100644 src/Web/Features/Contents/Handlers/UnfollowCreator.cs create mode 100644 src/Web/Features/Memberships/Handlers/ConfigureStripeAccount.cs diff --git a/src/Web/Common/BlobStorage/ContentTypes.cs b/src/Web/Common/BlobStorage/ContentTypes.cs index 438a2aa..e692ed5 100644 --- a/src/Web/Common/BlobStorage/ContentTypes.cs +++ b/src/Web/Common/BlobStorage/ContentTypes.cs @@ -1,10 +1,13 @@ -namespace Hutopy.Web.Common.BlobStorage; +using System.Text; + +namespace Hutopy.Web.Common.BlobStorage; public static class ContentTypes { private const string ImagePng = "image/png"; private const string ImageJpeg = "image/jpeg"; private const string ImageJpg = "image/jpg"; + private static string TextHtml = "text/html"; private static readonly HashSet AllowedContentTypes = [ImagePng, ImageJpeg, ImageJpg]; @@ -18,8 +21,8 @@ public static class ContentTypes private static bool IsValidFileType( Stream fileStream) { - byte[] buffer = new byte[4]; - fileStream.Read(buffer, 0, buffer.Length); + byte[] buffer = new byte[512]; + _ = fileStream.Read(buffer, 0, buffer.Length); fileStream.Position = 0; // PNG file signature: 89 50 4E 47 (in hex) @@ -33,6 +36,13 @@ public static class ContentTypes { return true; } + + // Check for HTML content by looking for "" or "" tags + string content = Encoding.UTF8.GetString(buffer); + if (content.Contains("")) + { + return true; + } return false; } diff --git a/src/Web/Features/Contents/Data/Content.cs b/src/Web/Features/Contents/Data/Content.cs index fcccd4b..307591c 100644 --- a/src/Web/Features/Contents/Data/Content.cs +++ b/src/Web/Features/Contents/Data/Content.cs @@ -12,7 +12,7 @@ public class Content public DateTimeOffset? DeletedAt { get; set; } [MaxLength(128)] public required string Title { get; set; } [MaxLength(2048)] public string Description { get; set; } = ""; - public string? HtmlFileUrl { get; set; } = ""; + [MaxLength(2048)] public string? HtmlFileUrl { get; set; } = ""; public IList Reactions { get; set; } = new List(); public string[]? Urls { get; init; } } diff --git a/src/Web/Features/Contents/Data/ContentDbContext.cs b/src/Web/Features/Contents/Data/ContentDbContext.cs index eb03f89..f72432f 100644 --- a/src/Web/Features/Contents/Data/ContentDbContext.cs +++ b/src/Web/Features/Contents/Data/ContentDbContext.cs @@ -8,7 +8,6 @@ public class ContentDbContext( public DbSet Contents => Set(); public DbSet Creators => Set(); - public DbSet Followers => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -31,16 +30,6 @@ public class ContentDbContext( .OwnsMany(c => c.Reactions) .ToTable("Reactions"); - modelBuilder - .Entity() - .HasOne(c => c.Creator) - .WithMany() - .HasForeignKey(c => c.CreatorId); - - modelBuilder - .Entity() - .HasKey(s => new { s.CreatedBy, s.CreatorId }); - modelBuilder .Entity() .OwnsOne(x => x.Socials) diff --git a/src/Web/Features/Contents/Data/Follower.cs b/src/Web/Features/Contents/Data/Follower.cs deleted file mode 100644 index c7368f1..0000000 --- a/src/Web/Features/Contents/Data/Follower.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Hutopy.Web.Features.Contents.Data; - -public class Follower -{ - public Guid CreatedBy { get; init; } - public DateTimeOffset CreatedAt { get; init; } - public Guid CreatorId { get; init; } - public Creator? Creator { get; set; } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240806065219_Initial.Designer.cs b/src/Web/Features/Contents/Data/Migrations/20240806065219_Initial.Designer.cs deleted file mode 100644 index 76dc6e2..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240806065219_Initial.Designer.cs +++ /dev/null @@ -1,258 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Contents.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.Contents.Migrations -{ - [DbContext(typeof(ContentDbContext))] - [Migration("20240806065219_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("Urls") - .HasColumnType("text[]"); - - b.HasKey("Id"); - - b.HasIndex("CreatedBy"); - - b.ToTable("Contents", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b.HasKey("Id"); - - b.ToTable("Creators", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatorId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CreatedBy", "CreatorId"); - - b.HasIndex("CreatorId"); - - b.ToTable("Subscriptions", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Description") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b1.Property("Title") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Creators", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Accent") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("BannerBottom") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("BannerTop") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Menu") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Colors", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Banner") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("Logo") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Images", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("FacebookUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("InstagramUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("LinkedInUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("RedditUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("TikTokUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("WebsiteUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("XUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("YoutubeUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Socials", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.Navigation("About") - .IsRequired(); - - b.Navigation("Colors") - .IsRequired(); - - b.Navigation("Images") - .IsRequired(); - - b.Navigation("Socials") - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240816212531_AddsSoftDelete.Designer.cs b/src/Web/Features/Contents/Data/Migrations/20240816212531_AddsSoftDelete.Designer.cs deleted file mode 100644 index 4ffcce3..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240816212531_AddsSoftDelete.Designer.cs +++ /dev/null @@ -1,264 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Contents.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.Contents.Migrations -{ - [DbContext(typeof(ContentDbContext))] - [Migration("20240816212531_AddsSoftDelete")] - partial class AddsSoftDelete - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("DeletedBy") - .HasColumnType("uuid"); - - b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("Urls") - .HasColumnType("text[]"); - - b.HasKey("Id"); - - b.HasIndex("CreatedBy"); - - b.ToTable("Contents", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b.HasKey("Id"); - - b.ToTable("Creators", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatorId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CreatedBy", "CreatorId"); - - b.HasIndex("CreatorId"); - - b.ToTable("Subscriptions", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Description") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b1.Property("Title") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Creators", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Accent") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("BannerBottom") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("BannerTop") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Menu") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Colors", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Banner") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("Logo") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Images", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("FacebookUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("InstagramUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("LinkedInUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("RedditUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("TikTokUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("WebsiteUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("XUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("YoutubeUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Socials", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.Navigation("About") - .IsRequired(); - - b.Navigation("Colors") - .IsRequired(); - - b.Navigation("Images") - .IsRequired(); - - b.Navigation("Socials") - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240816212531_AddsSoftDelete.cs b/src/Web/Features/Contents/Data/Migrations/20240816212531_AddsSoftDelete.cs deleted file mode 100644 index a6b528d..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240816212531_AddsSoftDelete.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Web.Features.Contents.Migrations -{ - /// - public partial class AddsSoftDelete : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "DeletedBy", - schema: "Content", - table: "Contents", - type: "uuid", - nullable: true); - - migrationBuilder.AddColumn( - name: "DeletedAt", - schema: "Content", - table: "Contents", - type: "timestamp with time zone", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "DeletedBy", - schema: "Content", - table: "Contents"); - - migrationBuilder.DropColumn( - name: "DeletedAt", - schema: "Content", - table: "Contents"); - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240824185551_AddReactionToContent.Designer.cs b/src/Web/Features/Contents/Data/Migrations/20240824185551_AddReactionToContent.Designer.cs deleted file mode 100644 index 8f13557..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240824185551_AddReactionToContent.Designer.cs +++ /dev/null @@ -1,296 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Contents.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.Contents.Migrations -{ - [DbContext(typeof(ContentDbContext))] - [Migration("20240824185551_AddReactionToContent")] - partial class AddReactionToContent - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DeletedBy") - .HasColumnType("uuid"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("Urls") - .HasColumnType("text[]"); - - b.HasKey("Id"); - - b.HasIndex("CreatedBy"); - - b.ToTable("Contents", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b.HasKey("Id"); - - b.ToTable("Creators", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatorId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CreatedBy", "CreatorId"); - - b.HasIndex("CreatorId"); - - b.ToTable("Subscriptions", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Hutopy.Web.Features.Contents.Data.ContentReaction", "Reactions", b1 => - { - b1.Property("ContentId") - .HasColumnType("uuid"); - - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); - - b1.Property("Reaction") - .HasColumnType("integer"); - - b1.Property("UserId") - .HasColumnType("uuid"); - - b1.Property("UserName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b1.HasKey("ContentId", "Id"); - - b1.ToTable("ContentReactions", "Content"); - - b1.WithOwner() - .HasForeignKey("ContentId"); - }); - - b.Navigation("Creator"); - - b.Navigation("Reactions"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Description") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b1.Property("Title") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Creators", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Accent") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("BannerBottom") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("BannerTop") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Menu") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Colors", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Banner") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("Logo") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Images", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("FacebookUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("InstagramUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("LinkedInUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("RedditUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("TikTokUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("WebsiteUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("XUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("YoutubeUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Socials", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.Navigation("About") - .IsRequired(); - - b.Navigation("Colors") - .IsRequired(); - - b.Navigation("Images") - .IsRequired(); - - b.Navigation("Socials") - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240824185551_AddReactionToContent.cs b/src/Web/Features/Contents/Data/Migrations/20240824185551_AddReactionToContent.cs deleted file mode 100644 index 6b28a31..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240824185551_AddReactionToContent.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Hutopy.Web.Features.Contents.Migrations -{ - /// - public partial class AddReactionToContent : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ContentReactions", - schema: "Content", - columns: table => new - { - ContentId = table.Column(type: "uuid", nullable: false), - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Reaction = table.Column(type: "integer", nullable: false), - UserId = table.Column(type: "uuid", nullable: false), - UserName = table.Column(type: "character varying(128)", maxLength: 128, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ContentReactions", x => new { x.ContentId, x.Id }); - table.ForeignKey( - name: "FK_ContentReactions_Contents_ContentId", - column: x => x.ContentId, - principalSchema: "Content", - principalTable: "Contents", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ContentReactions", - schema: "Content"); - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240919045548_UseMeterialColorSchema.Designer.cs b/src/Web/Features/Contents/Data/Migrations/20240919045548_UseMeterialColorSchema.Designer.cs deleted file mode 100644 index 2a6f961..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240919045548_UseMeterialColorSchema.Designer.cs +++ /dev/null @@ -1,320 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Contents.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.Contents.Migrations -{ - [DbContext(typeof(ContentDbContext))] - [Migration("20240919045548_UseMeterialColorSchema")] - partial class UseMeterialColorSchema - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DeletedBy") - .HasColumnType("uuid"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("Urls") - .HasColumnType("text[]"); - - b.HasKey("Id"); - - b.HasIndex("CreatedBy"); - - b.ToTable("Contents", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b.HasKey("Id"); - - b.ToTable("Creators", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatorId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CreatedBy", "CreatorId"); - - b.HasIndex("CreatorId"); - - b.ToTable("Subscriptions", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Hutopy.Web.Features.Contents.Data.ContentReaction", "Reactions", b1 => - { - b1.Property("ContentId") - .HasColumnType("uuid"); - - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); - - b1.Property("Reaction") - .HasColumnType("integer"); - - b1.Property("UserId") - .HasColumnType("uuid"); - - b1.Property("UserName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b1.HasKey("ContentId", "Id"); - - b1.ToTable("ContentReactions", "Content"); - - b1.WithOwner() - .HasForeignKey("ContentId"); - }); - - b.Navigation("Creator"); - - b.Navigation("Reactions"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Description") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b1.Property("Title") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Creators", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Background") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Error") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnBackground") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnError") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnPrimary") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnSecondary") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnSurface") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Primary") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Secondary") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Surface") - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Colors", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Banner") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("Logo") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Images", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("FacebookUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("InstagramUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("LinkedInUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("RedditUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("TikTokUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("WebsiteUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("XUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("YoutubeUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Socials", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.Navigation("About") - .IsRequired(); - - b.Navigation("Colors") - .IsRequired(); - - b.Navigation("Images") - .IsRequired(); - - b.Navigation("Socials") - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240919045548_UseMeterialColorSchema.cs b/src/Web/Features/Contents/Data/Migrations/20240919045548_UseMeterialColorSchema.cs deleted file mode 100644 index 400104e..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240919045548_UseMeterialColorSchema.cs +++ /dev/null @@ -1,144 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Web.Features.Contents.Migrations -{ - /// - public partial class UseMeterialColorSchema : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Menu", - schema: "Content", - table: "Colors", - newName: "Surface"); - - migrationBuilder.RenameColumn( - name: "BannerTop", - schema: "Content", - table: "Colors", - newName: "Secondary"); - - migrationBuilder.RenameColumn( - name: "BannerBottom", - schema: "Content", - table: "Colors", - newName: "Primary"); - - migrationBuilder.RenameColumn( - name: "Accent", - schema: "Content", - table: "Colors", - newName: "OnSurface"); - - migrationBuilder.AddColumn( - name: "Background", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true); - - migrationBuilder.AddColumn( - name: "Error", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true); - - migrationBuilder.AddColumn( - name: "OnBackground", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true); - - migrationBuilder.AddColumn( - name: "OnError", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true); - - migrationBuilder.AddColumn( - name: "OnPrimary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true); - - migrationBuilder.AddColumn( - name: "OnSecondary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Background", - schema: "Content", - table: "Colors"); - - migrationBuilder.DropColumn( - name: "Error", - schema: "Content", - table: "Colors"); - - migrationBuilder.DropColumn( - name: "OnBackground", - schema: "Content", - table: "Colors"); - - migrationBuilder.DropColumn( - name: "OnError", - schema: "Content", - table: "Colors"); - - migrationBuilder.DropColumn( - name: "OnPrimary", - schema: "Content", - table: "Colors"); - - migrationBuilder.DropColumn( - name: "OnSecondary", - schema: "Content", - table: "Colors"); - - migrationBuilder.RenameColumn( - name: "Surface", - schema: "Content", - table: "Colors", - newName: "Menu"); - - migrationBuilder.RenameColumn( - name: "Secondary", - schema: "Content", - table: "Colors", - newName: "BannerTop"); - - migrationBuilder.RenameColumn( - name: "Primary", - schema: "Content", - table: "Colors", - newName: "BannerBottom"); - - migrationBuilder.RenameColumn( - name: "OnSurface", - schema: "Content", - table: "Colors", - newName: "Accent"); - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240919051151_NoMoreOptionalColors.Designer.cs b/src/Web/Features/Contents/Data/Migrations/20240919051151_NoMoreOptionalColors.Designer.cs deleted file mode 100644 index 5793a13..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240919051151_NoMoreOptionalColors.Designer.cs +++ /dev/null @@ -1,330 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Contents.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.Contents.Migrations -{ - [DbContext(typeof(ContentDbContext))] - [Migration("20240919051151_NoMoreOptionalColors")] - partial class NoMoreOptionalColors - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DeletedBy") - .HasColumnType("uuid"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("Urls") - .HasColumnType("text[]"); - - b.HasKey("Id"); - - b.HasIndex("CreatedBy"); - - b.ToTable("Contents", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b.HasKey("Id"); - - b.ToTable("Creators", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatorId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CreatedBy", "CreatorId"); - - b.HasIndex("CreatorId"); - - b.ToTable("Subscriptions", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Hutopy.Web.Features.Contents.Data.ContentReaction", "Reactions", b1 => - { - b1.Property("ContentId") - .HasColumnType("uuid"); - - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); - - b1.Property("Reaction") - .HasColumnType("integer"); - - b1.Property("UserId") - .HasColumnType("uuid"); - - b1.Property("UserName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b1.HasKey("ContentId", "Id"); - - b1.ToTable("ContentReactions", "Content"); - - b1.WithOwner() - .HasForeignKey("ContentId"); - }); - - b.Navigation("Creator"); - - b.Navigation("Reactions"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Description") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b1.Property("Title") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Creators", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Background") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Error") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnBackground") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnError") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnPrimary") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnSecondary") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnSurface") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Primary") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Secondary") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Surface") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Colors", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Banner") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("Logo") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Images", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("FacebookUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("InstagramUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("LinkedInUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("RedditUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("TikTokUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("WebsiteUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("XUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("YoutubeUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Socials", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.Navigation("About") - .IsRequired(); - - b.Navigation("Colors") - .IsRequired(); - - b.Navigation("Images") - .IsRequired(); - - b.Navigation("Socials") - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240919051151_NoMoreOptionalColors.cs b/src/Web/Features/Contents/Data/Migrations/20240919051151_NoMoreOptionalColors.cs deleted file mode 100644 index 7af839e..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240919051151_NoMoreOptionalColors.cs +++ /dev/null @@ -1,258 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Web.Features.Contents.Migrations -{ - /// - public partial class NoMoreOptionalColors : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Surface", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Secondary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Primary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "OnSurface", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "OnSecondary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "OnPrimary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "OnError", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "OnBackground", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Error", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Background", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9, - oldNullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Surface", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "Secondary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "Primary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "OnSurface", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "OnSecondary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "OnPrimary", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "OnError", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "OnBackground", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "Error", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - - migrationBuilder.AlterColumn( - name: "Background", - schema: "Content", - table: "Colors", - type: "character varying(9)", - maxLength: 9, - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(9)", - oldMaxLength: 9); - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240922064815_RemovesAboutAddsTitle.Designer.cs b/src/Web/Features/Contents/Data/Migrations/20240922064815_RemovesAboutAddsTitle.Designer.cs deleted file mode 100644 index 5a5cb91..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240922064815_RemovesAboutAddsTitle.Designer.cs +++ /dev/null @@ -1,310 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Contents.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.Contents.Migrations -{ - [DbContext(typeof(ContentDbContext))] - [Migration("20240922064815_RemovesAboutAddsTitle")] - partial class RemovesAboutAddsTitle - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("DeletedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("DeletedBy") - .HasColumnType("uuid"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("Urls") - .HasColumnType("text[]"); - - b.HasKey("Id"); - - b.HasIndex("CreatedBy"); - - b.ToTable("Contents", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b.HasKey("Id"); - - b.ToTable("Creators", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatorId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CreatedBy", "CreatorId"); - - b.HasIndex("CreatorId"); - - b.ToTable("Subscriptions", "Content"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Hutopy.Web.Features.Contents.Data.ContentReaction", "Reactions", b1 => - { - b1.Property("ContentId") - .HasColumnType("uuid"); - - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); - - b1.Property("Reaction") - .HasColumnType("integer"); - - b1.Property("UserId") - .HasColumnType("uuid"); - - b1.Property("UserName") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b1.HasKey("ContentId", "Id"); - - b1.ToTable("ContentReactions", "Content"); - - b1.WithOwner() - .HasForeignKey("ContentId"); - }); - - b.Navigation("Creator"); - - b.Navigation("Reactions"); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => - { - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Background") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Error") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnBackground") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnError") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnPrimary") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnSecondary") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("OnSurface") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Primary") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Secondary") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.Property("Surface") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("character varying(9)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Colors", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Banner") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("Logo") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Images", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("FacebookUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("InstagramUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("LinkedInUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("RedditUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("TikTokUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("WebsiteUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("XUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.Property("YoutubeUrl") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Socials", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - - b.Navigation("Colors") - .IsRequired(); - - b.Navigation("Images") - .IsRequired(); - - b.Navigation("Socials") - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20240922064815_RemovesAboutAddsTitle.cs b/src/Web/Features/Contents/Data/Migrations/20240922064815_RemovesAboutAddsTitle.cs deleted file mode 100644 index ff88fb5..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20240922064815_RemovesAboutAddsTitle.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Web.Features.Contents.Migrations -{ - /// - public partial class RemovesAboutAddsTitle : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "About_Description", - schema: "Content", - table: "Creators"); - - migrationBuilder.RenameColumn( - name: "About_Title", - schema: "Content", - table: "Creators", - newName: "Title"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "Title", - schema: "Content", - table: "Creators", - newName: "About_Title"); - - migrationBuilder.AddColumn( - name: "About_Description", - schema: "Content", - table: "Creators", - type: "character varying(2048)", - maxLength: 2048, - nullable: true); - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20241011103653_FromSubscribersToFollowers.cs b/src/Web/Features/Contents/Data/Migrations/20241011103653_FromSubscribersToFollowers.cs deleted file mode 100644 index 8f41082..0000000 --- a/src/Web/Features/Contents/Data/Migrations/20241011103653_FromSubscribersToFollowers.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Web.Features.Contents.Migrations -{ - /// - public partial class FromSubscribersToFollowers : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Subscriptions", - schema: "Content"); - - migrationBuilder.CreateTable( - name: "Followers", - schema: "Content", - columns: table => new - { - CreatedBy = table.Column(type: "uuid", nullable: false), - CreatorId = table.Column(type: "uuid", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Followers", x => new { x.CreatedBy, x.CreatorId }); - table.ForeignKey( - name: "FK_Followers_Creators_CreatorId", - column: x => x.CreatorId, - principalSchema: "Content", - principalTable: "Creators", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Followers_CreatorId", - schema: "Content", - table: "Followers", - column: "CreatorId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Followers", - schema: "Content"); - - migrationBuilder.CreateTable( - name: "Subscriptions", - schema: "Content", - columns: table => new - { - CreatedBy = table.Column(type: "uuid", nullable: false), - CreatorId = table.Column(type: "uuid", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Subscriptions", x => new { x.CreatedBy, x.CreatorId }); - table.ForeignKey( - name: "FK_Subscriptions_Creators_CreatorId", - column: x => x.CreatorId, - principalSchema: "Content", - principalTable: "Creators", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Subscriptions_CreatorId", - schema: "Content", - table: "Subscriptions", - column: "CreatorId"); - } - } -} diff --git a/src/Web/Features/Contents/Data/Migrations/20241011103653_FromSubscribersToFollowers.Designer.cs b/src/Web/Features/Contents/Data/Migrations/20241020202641_Initial.Designer.cs similarity index 89% rename from src/Web/Features/Contents/Data/Migrations/20241011103653_FromSubscribersToFollowers.Designer.cs rename to src/Web/Features/Contents/Data/Migrations/20241020202641_Initial.Designer.cs index 4d4fd2b..95015b2 100644 --- a/src/Web/Features/Contents/Data/Migrations/20241011103653_FromSubscribersToFollowers.Designer.cs +++ b/src/Web/Features/Contents/Data/Migrations/20241020202641_Initial.Designer.cs @@ -9,11 +9,11 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable -namespace Hutopy.Web.Features.Contents.Migrations +namespace Hutopy.Web.Features.Contents.Data.Migrations { [DbContext(typeof(ContentDbContext))] - [Migration("20241011103653_FromSubscribersToFollowers")] - partial class FromSubscribersToFollowers + [Migration("20241020202641_Initial")] + partial class Initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -21,7 +21,7 @@ namespace Hutopy.Web.Features.Contents.Migrations #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -51,6 +51,10 @@ namespace Hutopy.Web.Features.Contents.Migrations .HasMaxLength(2048) .HasColumnType("character varying(2048)"); + b.Property("HtmlFileUrl") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + b.Property("Title") .IsRequired() .HasMaxLength(128) @@ -92,24 +96,6 @@ namespace Hutopy.Web.Features.Contents.Migrations b.ToTable("Creators", "Content"); }); - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Follower", b => - { - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatorId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CreatedBy", "CreatorId"); - - b.HasIndex("CreatorId"); - - b.ToTable("Followers", "Content"); - }); - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => { b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") @@ -142,7 +128,7 @@ namespace Hutopy.Web.Features.Contents.Migrations b1.HasKey("ContentId", "Id"); - b1.ToTable("ContentReactions", "Content"); + b1.ToTable("Reactions", "Content"); b1.WithOwner() .HasForeignKey("ContentId"); @@ -293,17 +279,6 @@ namespace Hutopy.Web.Features.Contents.Migrations b.Navigation("Socials") .IsRequired(); }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Follower", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); #pragma warning restore 612, 618 } } diff --git a/src/Web/Features/Contents/Data/Migrations/20240806065219_Initial.cs b/src/Web/Features/Contents/Data/Migrations/20241020202641_Initial.cs similarity index 74% rename from src/Web/Features/Contents/Data/Migrations/20240806065219_Initial.cs rename to src/Web/Features/Contents/Data/Migrations/20241020202641_Initial.cs index 6ceb9b5..37b0eb8 100644 --- a/src/Web/Features/Contents/Data/Migrations/20240806065219_Initial.cs +++ b/src/Web/Features/Contents/Data/Migrations/20241020202641_Initial.cs @@ -1,9 +1,10 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable -namespace Hutopy.Web.Features.Contents.Migrations +namespace Hutopy.Web.Features.Contents.Data.Migrations { /// public partial class Initial : Migration @@ -23,8 +24,7 @@ namespace Hutopy.Web.Features.Contents.Migrations CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), Name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), - About_Title = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), - About_Description = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true) + Title = table.Column(type: "character varying(255)", maxLength: 255, nullable: true) }, constraints: table => { @@ -37,10 +37,16 @@ namespace Hutopy.Web.Features.Contents.Migrations columns: table => new { CreatorId = table.Column(type: "uuid", nullable: false), - BannerTop = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), - BannerBottom = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), - Accent = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), - Menu = table.Column(type: "character varying(9)", maxLength: 9, nullable: true) + Primary = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + Secondary = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + Background = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + Surface = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + Error = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + OnPrimary = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + OnSecondary = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + OnBackground = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + OnSurface = table.Column(type: "character varying(9)", maxLength: 9, nullable: false), + OnError = table.Column(type: "character varying(9)", maxLength: 9, nullable: false) }, constraints: table => { @@ -62,8 +68,11 @@ namespace Hutopy.Web.Features.Contents.Migrations Id = table.Column(type: "uuid", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DeletedBy = table.Column(type: "uuid", nullable: true), + DeletedAt = table.Column(type: "timestamp with time zone", nullable: true), Title = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), Description = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: false), + HtmlFileUrl = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true), Urls = table.Column(type: "text[]", nullable: true) }, constraints: table => @@ -127,22 +136,25 @@ namespace Hutopy.Web.Features.Contents.Migrations }); migrationBuilder.CreateTable( - name: "Subscriptions", + name: "Reactions", schema: "Content", columns: table => new { - CreatedBy = table.Column(type: "uuid", nullable: false), - CreatorId = table.Column(type: "uuid", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + ContentId = table.Column(type: "uuid", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Reaction = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "uuid", nullable: false), + UserName = table.Column(type: "character varying(128)", maxLength: 128, nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Subscriptions", x => new { x.CreatedBy, x.CreatorId }); + table.PrimaryKey("PK_Reactions", x => new { x.ContentId, x.Id }); table.ForeignKey( - name: "FK_Subscriptions_Creators_CreatorId", - column: x => x.CreatorId, + name: "FK_Reactions_Contents_ContentId", + column: x => x.ContentId, principalSchema: "Content", - principalTable: "Creators", + principalTable: "Contents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -152,12 +164,6 @@ namespace Hutopy.Web.Features.Contents.Migrations schema: "Content", table: "Contents", column: "CreatedBy"); - - migrationBuilder.CreateIndex( - name: "IX_Subscriptions_CreatorId", - schema: "Content", - table: "Subscriptions", - column: "CreatorId"); } /// @@ -168,11 +174,11 @@ namespace Hutopy.Web.Features.Contents.Migrations schema: "Content"); migrationBuilder.DropTable( - name: "Contents", + name: "Images", schema: "Content"); migrationBuilder.DropTable( - name: "Images", + name: "Reactions", schema: "Content"); migrationBuilder.DropTable( @@ -180,7 +186,7 @@ namespace Hutopy.Web.Features.Contents.Migrations schema: "Content"); migrationBuilder.DropTable( - name: "Subscriptions", + name: "Contents", schema: "Content"); migrationBuilder.DropTable( diff --git a/src/Web/Features/Contents/Data/Migrations/ContentDbContextModelSnapshot.cs b/src/Web/Features/Contents/Data/Migrations/ContentDbContextModelSnapshot.cs index 2f630c6..eeaa08b 100644 --- a/src/Web/Features/Contents/Data/Migrations/ContentDbContextModelSnapshot.cs +++ b/src/Web/Features/Contents/Data/Migrations/ContentDbContextModelSnapshot.cs @@ -8,7 +8,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable -namespace Hutopy.Web.Features.Contents.Migrations +namespace Hutopy.Web.Features.Contents.Data.Migrations { [DbContext(typeof(ContentDbContext))] partial class ContentDbContextModelSnapshot : ModelSnapshot @@ -18,7 +18,7 @@ namespace Hutopy.Web.Features.Contents.Migrations #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -49,7 +49,8 @@ namespace Hutopy.Web.Features.Contents.Migrations .HasColumnType("character varying(2048)"); b.Property("HtmlFileUrl") - .HasColumnType("text"); + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); b.Property("Title") .IsRequired() @@ -92,24 +93,6 @@ namespace Hutopy.Web.Features.Contents.Migrations b.ToTable("Creators", "Content"); }); - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Follower", b => - { - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatorId") - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("CreatedBy", "CreatorId"); - - b.HasIndex("CreatorId"); - - b.ToTable("Followers", "Content"); - }); - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => { b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") @@ -142,7 +125,7 @@ namespace Hutopy.Web.Features.Contents.Migrations b1.HasKey("ContentId", "Id"); - b1.ToTable("ContentReactions", "Content"); + b1.ToTable("Reactions", "Content"); b1.WithOwner() .HasForeignKey("ContentId"); @@ -293,17 +276,6 @@ namespace Hutopy.Web.Features.Contents.Migrations b.Navigation("Socials") .IsRequired(); }); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Follower", b => - { - b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") - .WithMany() - .HasForeignKey("CreatorId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Creator"); - }); #pragma warning restore 612, 618 } } diff --git a/src/Web/Features/Contents/Handlers/CreateContentFromHtml.cs b/src/Web/Features/Contents/Handlers/CreateContentFromHtml.cs index 22a055c..a09a39b 100644 --- a/src/Web/Features/Contents/Handlers/CreateContentFromHtml.cs +++ b/src/Web/Features/Contents/Handlers/CreateContentFromHtml.cs @@ -1,7 +1,6 @@ using System.Text; -using Hutopy.Application.AzureBlobStorage.Constants; -using Hutopy.Application.Common.Interfaces; -using Hutopy.Web.Common; +using Hutopy.Web.Common.BlobStorage; +using Hutopy.Web.Common.Security; using Hutopy.Web.Features.Contents.Data; using Hutopy.Web.Features.Contents.Handlers.Models; @@ -13,7 +12,7 @@ public record PostContentFromHtmlRequest( Guid CreatorId, string Title, string HtmlContent - ); +); [PublicAPI] public sealed class PostContentFromHtmlRequestValidator : Validator @@ -35,7 +34,7 @@ public sealed class PostContentFromHtmlRequestValidator : Validator { @@ -51,19 +50,13 @@ public sealed class PostContentHtml( CancellationToken ct) { var htmlFileUrl = await SaveHtmlContentAsHtmlFileAsync( - req.CreatorId, - req.Id, - req.HtmlContent, + req.CreatorId, + req.Id, + req.HtmlContent, ct); - + await context.Contents.AddAsync( - new Content - { - Id = req.Id, - CreatedBy = User.GetUserId(), - Title = req.Title, - HtmlFileUrl = htmlFileUrl - }, + new Content { Id = req.Id, CreatedBy = User.GetUserId(), Title = req.Title, HtmlFileUrl = htmlFileUrl }, ct); await context.SaveChangesAsync(ct); diff --git a/src/Web/Features/Contents/Handlers/FollowCreator.cs b/src/Web/Features/Contents/Handlers/FollowCreator.cs deleted file mode 100644 index 3025b0c..0000000 --- a/src/Web/Features/Contents/Handlers/FollowCreator.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Hutopy.Web.Common; -using Hutopy.Web.Common.Security; -using Hutopy.Web.Features.Contents.Data; -using Hutopy.Web.Features.Contents.Handlers.Models; - -namespace Hutopy.Web.Features.Contents.Handlers; - -[PublicAPI] -public sealed class FollowCreatorRequest -{ - public Guid CreatorId { get; set; } -} - -[PublicAPI] -public sealed class FollowCreatorHandler( - ContentDbContext context) - : Endpoint -{ - public override void Configure() - { - Post("/api/creators/{CreatorId}/follow"); - Options((o => o.WithTags("creators"))); - Description(x => x.Accepts("*/*")); - } - - public override async Task HandleAsync( - FollowCreatorRequest req, - CancellationToken ct) - { - await context.Followers.AddAsync( - new Follower { CreatedBy = User.GetUserId(), CreatorId = req.CreatorId }, - ct); - - await context.SaveChangesAsync(ct); - - var creator = await context - .Creators - .Where(creator => creator.Id == req.CreatorId) - .Select(creator => new FollowModel( - req.CreatorId, - creator.Name, - creator.Images.Logo - )) - .FirstOrDefaultAsync(cancellationToken: ct); - - if (creator is null) - { - await SendNotFoundAsync(ct); - } - else - { - await SendOkAsync(creator, ct); - } - } -} diff --git a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs index c53d2a6..351bdc3 100644 --- a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs +++ b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs @@ -50,10 +50,6 @@ public class GetCreatorByAliasHandler( } else { - var followerCount = await context.Followers.CountAsync( - s => s.CreatorId == creator.Id, - cancellationToken: ct); - var model = new CreatorModel( creator.Id, creator.CreatedBy, @@ -62,8 +58,7 @@ public class GetCreatorByAliasHandler( creator.Title, creator.Socials, creator.Colors, - creator.Images, - followerCount); + creator.Images); await SendAsync(model, cancellation: ct); } diff --git a/src/Web/Features/Contents/Handlers/GetFollowedCreators.cs b/src/Web/Features/Contents/Handlers/GetFollowedCreators.cs deleted file mode 100644 index c8560fd..0000000 --- a/src/Web/Features/Contents/Handlers/GetFollowedCreators.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Hutopy.Web.Common; -using Hutopy.Web.Common.Security; -using Hutopy.Web.Features.Contents.Data; -using Hutopy.Web.Features.Contents.Handlers.Models; - -namespace Hutopy.Web.Features.Contents.Handlers; - -[PublicAPI] -public class GetFollowedCreatorsHandler( - ContentDbContext context) - : EndpointWithoutRequest> -{ - public override void Configure() - { - Get("/api/creators/followed"); - Options((o => o.WithTags("Creators"))); - } - - public override async Task HandleAsync( - CancellationToken ct) - { - var userId = HttpContext.User.GetUserId(); - - var subscriptions = await context - .Followers - .Where(s => s.CreatedBy == userId) - .Select(s => new FollowModel( - s.CreatorId, - s.Creator!.Name, - s.Creator.Images.Logo)) - .ToListAsync(cancellationToken: ct); - - await SendOkAsync(subscriptions, ct); - } -} diff --git a/src/Web/Features/Contents/Handlers/InsertImage.cs b/src/Web/Features/Contents/Handlers/InsertImage.cs index 5db7d5c..49c31b0 100644 --- a/src/Web/Features/Contents/Handlers/InsertImage.cs +++ b/src/Web/Features/Contents/Handlers/InsertImage.cs @@ -1,5 +1,4 @@ -using Hutopy.Application.AzureBlobStorage.Constants; -using Hutopy.Application.Common.Interfaces; +using Hutopy.Web.Common.BlobStorage; namespace Hutopy.Web.Features.Contents.Handlers; @@ -8,7 +7,7 @@ public record InsertImagesRequest( Guid Id, Guid CreatorId, IFormFileCollection? Files - ); +); [PublicAPI] public sealed class InsertImagesRequestValidator : Validator @@ -25,7 +24,9 @@ public sealed class InsertImagesRequestValidator : Validator +public sealed class InsertImages( + AzureBlobStorage blobStorage) + : Endpoint { public override void Configure() { @@ -63,6 +64,7 @@ public sealed class InsertImages(IBlobStorage blobStorage) : Endpoint -{ - public override void Configure() - { - Post("/api/creators/{CreatorId}/unfollow"); - Options((o => o.WithTags("Creators"))); - Description(x => x.Accepts("*/*")); - } - - public override async Task HandleAsync( - UnsubscribeFromCreatorRequest req, - CancellationToken ct) - { - try - { - var subscription = new Follower { CreatorId = req.CreatorId, CreatedBy = HttpContext.User.GetUserId() }; - - context.Followers.Attach(subscription); - context.Followers.Remove(subscription); - - await context.SaveChangesAsync(ct); - - await SendOkAsync(ct); - } - catch (Exception) - { - await SendNotFoundAsync(ct); - } - } -} diff --git a/src/Web/Features/Memberships/Handlers/ConfigureStripeAccount.cs b/src/Web/Features/Memberships/Handlers/ConfigureStripeAccount.cs new file mode 100644 index 0000000..f9fabb3 --- /dev/null +++ b/src/Web/Features/Memberships/Handlers/ConfigureStripeAccount.cs @@ -0,0 +1,52 @@ +using Hutopy.Web.Common.Security; +using Hutopy.Web.Features.Memberships.Data; +using Hutopy.Web.Features.Memberships.Services; + +namespace Hutopy.Web.Features.Memberships.Handlers; + +[PublicAPI] +public record struct ConfigureStripeAccountRequest( + Guid SubscriptionId, + string StripeAccountId); + +public class ConfigureStripeAccountHandler( + MembershipDbContext dbContext, + StripeService stripeService) + : Endpoint +{ + public override void Configure() + { + Post("/api/membership/stripe-account"); + Options(o => o.WithTags("Memberships")); + } + + public override async Task HandleAsync( + ConfigureStripeAccountRequest req, + CancellationToken ct) + { + var creatorId = HttpContext.User.GetUserId(); + + var creator = await dbContext + .Creators + .FindAsync( + [creatorId], + cancellationToken: ct); + + if (creator is null) + { + creator = new Creator + { + Id = creatorId, + Name = HttpContext.User.GetAlias() ?? creatorId.ToString() + }; + + await dbContext.AddAsync(creator, ct); + } + + creator.StripeAccountId = req.StripeAccountId; + + await dbContext.SaveChangesAsync(ct); + + await SendOkAsync(creator.Id, ct); + } +} diff --git a/src/Web/TestDataSeeder.cs b/src/Web/TestDataSeeder.cs index 2b2d48d..5b0bef7 100644 --- a/src/Web/TestDataSeeder.cs +++ b/src/Web/TestDataSeeder.cs @@ -48,10 +48,6 @@ internal class TestDataSeeder( creator.Id = creatorUser.Id; creator.CreatedBy = creator.Id; - await contentContext.Followers.AddAsync(new Follower - { - CreatedBy = userA.Id, CreatorId = creator.Id - }); await contentContext.Creators.AddAsync(creator); var contents = GenerateContent(creator, 10); diff --git a/src/Web/Web.csproj b/src/Web/Web.csproj index a4bea51..09a4a6e 100644 --- a/src/Web/Web.csproj +++ b/src/Web/Web.csproj @@ -30,7 +30,13 @@ + + + + + +