From 6f9ed0668ffb1816e766e49277228386679ea833 Mon Sep 17 00:00:00 2001 From: dingo Date: Wed, 25 Feb 2026 07:52:30 -0500 Subject: [PATCH] Add EF Core migrations and SuperAdmin seeder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Generated InitialCreate migrations for all 5 DbContexts: identity, catalog, collection, bazaar, chat (separate Postgres schemas) - Applied to pg-forge-01 (172.10.1.127) — all schemas live - Program.cs: SeedAsync() creates SuperAdmin + Admin roles and seeds initial SuperAdmin account on startup if none exists (email/password overridable via Admin:Email / Admin:Password config) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Server/src/SOR.Admin/Program.cs | 36 ++ .../20260225124943_InitialCreate.Designer.cs | 135 +++++++ .../Bazaar/20260225124943_InitialCreate.cs | 119 +++++++ .../Bazaar/BazaarDbContextModelSnapshot.cs | 132 +++++++ .../20260225124936_InitialCreate.Designer.cs | 303 ++++++++++++++++ .../Catalog/20260225124936_InitialCreate.cs | 213 +++++++++++ .../Catalog/CatalogDbContextModelSnapshot.cs | 300 ++++++++++++++++ .../20260225124946_InitialCreate.Designer.cs | 151 ++++++++ .../Chat/20260225124946_InitialCreate.cs | 135 +++++++ .../Chat/ChatDbContextModelSnapshot.cs | 148 ++++++++ .../20260225124939_InitialCreate.Designer.cs | 135 +++++++ .../20260225124939_InitialCreate.cs | 117 ++++++ .../CollectionDbContextModelSnapshot.cs | 132 +++++++ .../20260225124925_InitialCreate.Designer.cs | 332 ++++++++++++++++++ .../Identity/20260225124925_InitialCreate.cs | 300 ++++++++++++++++ .../SorIdentityDbContextModelSnapshot.cs | 329 +++++++++++++++++ 16 files changed, 3017 insertions(+) create mode 100644 Server/src/SOR.Database/Migrations/Bazaar/20260225124943_InitialCreate.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Bazaar/20260225124943_InitialCreate.cs create mode 100644 Server/src/SOR.Database/Migrations/Bazaar/BazaarDbContextModelSnapshot.cs create mode 100644 Server/src/SOR.Database/Migrations/Catalog/20260225124936_InitialCreate.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Catalog/20260225124936_InitialCreate.cs create mode 100644 Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs create mode 100644 Server/src/SOR.Database/Migrations/Chat/20260225124946_InitialCreate.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Chat/20260225124946_InitialCreate.cs create mode 100644 Server/src/SOR.Database/Migrations/Chat/ChatDbContextModelSnapshot.cs create mode 100644 Server/src/SOR.Database/Migrations/Collection/20260225124939_InitialCreate.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Collection/20260225124939_InitialCreate.cs create mode 100644 Server/src/SOR.Database/Migrations/Collection/CollectionDbContextModelSnapshot.cs create mode 100644 Server/src/SOR.Database/Migrations/Identity/20260225124925_InitialCreate.Designer.cs create mode 100644 Server/src/SOR.Database/Migrations/Identity/20260225124925_InitialCreate.cs create mode 100644 Server/src/SOR.Database/Migrations/Identity/SorIdentityDbContextModelSnapshot.cs diff --git a/Server/src/SOR.Admin/Program.cs b/Server/src/SOR.Admin/Program.cs index 6531c37..f8980f6 100644 --- a/Server/src/SOR.Admin/Program.cs +++ b/Server/src/SOR.Admin/Program.cs @@ -125,4 +125,40 @@ app.MapRazorPages(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); +// ── Seed roles and initial SuperAdmin ───────────────────────────────────── +await SeedAsync(app); + app.Run(); + +static async Task SeedAsync(WebApplication app) +{ + using var scope = app.Services.CreateScope(); + var roleManager = scope.ServiceProvider.GetRequiredService>>(); + var userManager = scope.ServiceProvider.GetRequiredService>(); + var cfg = scope.ServiceProvider.GetRequiredService(); + + foreach (var role in new[] { "SuperAdmin", "Admin" }) + { + if (!await roleManager.RoleExistsAsync(role)) + await roleManager.CreateAsync(new IdentityRole(role)); + } + + // Create the first SuperAdmin if none exists. + // Override via appsettings / env vars: Admin:Email Admin:Password + var email = cfg["Admin:Email"] ?? "admin@sor.local"; + var password = cfg["Admin:Password"] ?? "Admin@SOR2026!"; + + if (await userManager.FindByEmailAsync(email) is null) + { + var account = new Account + { + UserName = email, + Email = email, + DisplayName = "Super Admin", + CreatedAt = DateTimeOffset.UtcNow, + }; + var result = await userManager.CreateAsync(account, password); + if (result.Succeeded) + await userManager.AddToRoleAsync(account, "SuperAdmin"); + } +} diff --git a/Server/src/SOR.Database/Migrations/Bazaar/20260225124943_InitialCreate.Designer.cs b/Server/src/SOR.Database/Migrations/Bazaar/20260225124943_InitialCreate.Designer.cs new file mode 100644 index 0000000..2310e64 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Bazaar/20260225124943_InitialCreate.Designer.cs @@ -0,0 +1,135 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Bazaar +{ + [DbContext(typeof(BazaarDbContext))] + [Migration("20260225124943_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("bazaar") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("Currency") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ListedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ListingType") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlayerCardId") + .HasColumnType("uuid"); + + b.Property("Price") + .HasColumnType("numeric(18,4)"); + + b.Property("SellerAccountId") + .HasColumnType("uuid"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("SellerAccountId"); + + b.HasIndex("Status", "CardDefinitionId"); + + b.HasIndex("Status", "ExpiresAt"); + + b.ToTable("listings", "bazaar"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("numeric(18,4)"); + + b.Property("BuyerAccountId") + .HasColumnType("uuid"); + + b.Property("Currency") + .IsRequired() + .HasColumnType("text"); + + b.Property("ListingId") + .HasColumnType("uuid"); + + b.Property("PlayerCardId") + .HasColumnType("uuid"); + + b.Property("SellerAccountId") + .HasColumnType("uuid"); + + b.Property("TransactedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BuyerAccountId"); + + b.HasIndex("ListingId"); + + b.HasIndex("SellerAccountId"); + + b.HasIndex("TransactedAt"); + + b.ToTable("transactions", "bazaar"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b => + { + b.HasOne("SOR.Database.Entities.Bazaar.BazaarListing", "Listing") + .WithMany("Transactions") + .HasForeignKey("ListingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Listing"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b => + { + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Bazaar/20260225124943_InitialCreate.cs b/Server/src/SOR.Database/Migrations/Bazaar/20260225124943_InitialCreate.cs new file mode 100644 index 0000000..f6a2910 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Bazaar/20260225124943_InitialCreate.cs @@ -0,0 +1,119 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SOR.Database.Migrations.Bazaar +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "bazaar"); + + migrationBuilder.CreateTable( + name: "listings", + schema: "bazaar", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + SellerAccountId = table.Column(type: "uuid", nullable: false), + PlayerCardId = table.Column(type: "uuid", nullable: false), + CardDefinitionId = table.Column(type: "uuid", nullable: false), + ListingType = table.Column(type: "text", nullable: false), + Price = table.Column(type: "numeric(18,4)", nullable: false), + Currency = table.Column(type: "text", nullable: false), + ListedAt = table.Column(type: "timestamp with time zone", nullable: false), + ExpiresAt = table.Column(type: "timestamp with time zone", nullable: true), + Status = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_listings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "transactions", + schema: "bazaar", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ListingId = table.Column(type: "uuid", nullable: false), + BuyerAccountId = table.Column(type: "uuid", nullable: false), + SellerAccountId = table.Column(type: "uuid", nullable: false), + PlayerCardId = table.Column(type: "uuid", nullable: false), + Amount = table.Column(type: "numeric(18,4)", nullable: false), + Currency = table.Column(type: "text", nullable: false), + TransactedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_transactions", x => x.Id); + table.ForeignKey( + name: "FK_transactions_listings_ListingId", + column: x => x.ListingId, + principalSchema: "bazaar", + principalTable: "listings", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_listings_SellerAccountId", + schema: "bazaar", + table: "listings", + column: "SellerAccountId"); + + migrationBuilder.CreateIndex( + name: "IX_listings_Status_CardDefinitionId", + schema: "bazaar", + table: "listings", + columns: new[] { "Status", "CardDefinitionId" }); + + migrationBuilder.CreateIndex( + name: "IX_listings_Status_ExpiresAt", + schema: "bazaar", + table: "listings", + columns: new[] { "Status", "ExpiresAt" }); + + migrationBuilder.CreateIndex( + name: "IX_transactions_BuyerAccountId", + schema: "bazaar", + table: "transactions", + column: "BuyerAccountId"); + + migrationBuilder.CreateIndex( + name: "IX_transactions_ListingId", + schema: "bazaar", + table: "transactions", + column: "ListingId"); + + migrationBuilder.CreateIndex( + name: "IX_transactions_SellerAccountId", + schema: "bazaar", + table: "transactions", + column: "SellerAccountId"); + + migrationBuilder.CreateIndex( + name: "IX_transactions_TransactedAt", + schema: "bazaar", + table: "transactions", + column: "TransactedAt"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "transactions", + schema: "bazaar"); + + migrationBuilder.DropTable( + name: "listings", + schema: "bazaar"); + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Bazaar/BazaarDbContextModelSnapshot.cs b/Server/src/SOR.Database/Migrations/Bazaar/BazaarDbContextModelSnapshot.cs new file mode 100644 index 0000000..1af3035 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Bazaar/BazaarDbContextModelSnapshot.cs @@ -0,0 +1,132 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Bazaar +{ + [DbContext(typeof(BazaarDbContext))] + partial class BazaarDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("bazaar") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("Currency") + .IsRequired() + .HasColumnType("text"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ListedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ListingType") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlayerCardId") + .HasColumnType("uuid"); + + b.Property("Price") + .HasColumnType("numeric(18,4)"); + + b.Property("SellerAccountId") + .HasColumnType("uuid"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("SellerAccountId"); + + b.HasIndex("Status", "CardDefinitionId"); + + b.HasIndex("Status", "ExpiresAt"); + + b.ToTable("listings", "bazaar"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Amount") + .HasColumnType("numeric(18,4)"); + + b.Property("BuyerAccountId") + .HasColumnType("uuid"); + + b.Property("Currency") + .IsRequired() + .HasColumnType("text"); + + b.Property("ListingId") + .HasColumnType("uuid"); + + b.Property("PlayerCardId") + .HasColumnType("uuid"); + + b.Property("SellerAccountId") + .HasColumnType("uuid"); + + b.Property("TransactedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BuyerAccountId"); + + b.HasIndex("ListingId"); + + b.HasIndex("SellerAccountId"); + + b.HasIndex("TransactedAt"); + + b.ToTable("transactions", "bazaar"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarTransaction", b => + { + b.HasOne("SOR.Database.Entities.Bazaar.BazaarListing", "Listing") + .WithMany("Transactions") + .HasForeignKey("ListingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Listing"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Bazaar.BazaarListing", b => + { + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/20260225124936_InitialCreate.Designer.cs b/Server/src/SOR.Database/Migrations/Catalog/20260225124936_InitialCreate.Designer.cs new file mode 100644 index 0000000..61e8acc --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/20260225124936_InitialCreate.Designer.cs @@ -0,0 +1,303 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Catalog +{ + [DbContext(typeof(CatalogDbContext))] + [Migration("20260225124936_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("catalog") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("AnimationCdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CardDefinitionId", "ActionName") + .IsUnique(); + + b.ToTable("card_animation_bindings", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AssetType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MimeType") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CardDefinitionId", "AssetType"); + + b.ToTable("card_assets", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AbilitiesJson") + .HasColumnType("jsonb") + .HasColumnName("abilities"); + + b.Property("Affinity") + .IsRequired() + .HasColumnType("text"); + + b.Property("AttackType") + .HasColumnType("text"); + + b.Property("CanAttack") + .HasColumnType("boolean"); + + b.Property("CanBeAttacked") + .HasColumnType("boolean"); + + b.Property("CanBeBlocked") + .HasColumnType("boolean"); + + b.Property("CanBeObstructed") + .HasColumnType("boolean"); + + b.Property("CanBeSacrificed") + .HasColumnType("boolean"); + + b.Property("CanDefend") + .HasColumnType("boolean"); + + b.Property("CanMove") + .HasColumnType("boolean"); + + b.Property("CanUseAbility") + .HasColumnType("boolean"); + + b.Property("CardType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CollectorNumber") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Damage") + .HasColumnType("integer"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EffectsJson") + .HasColumnType("jsonb") + .HasColumnName("effects"); + + b.Property("Genus") + .HasColumnType("text[]"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("MaxAttackRange") + .HasColumnType("integer"); + + b.Property("MaxChannelRange") + .HasColumnType("integer"); + + b.Property("MaxDefense") + .HasColumnType("integer"); + + b.Property("MaxHealth") + .HasColumnType("integer"); + + b.Property("MinAttackRange") + .HasColumnType("integer"); + + b.Property("MinChannelRange") + .HasColumnType("integer"); + + b.Property("MovementPoints") + .HasColumnType("integer"); + + b.Property("MovementType") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherCostsJson") + .HasColumnType("jsonb") + .HasColumnName("other_costs"); + + b.Property("Rarity") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequiresLos") + .HasColumnType("boolean"); + + b.Property("SetId") + .HasColumnType("uuid"); + + b.Property("SpCost") + .HasColumnType("integer"); + + b.Property("StCost") + .HasColumnType("integer"); + + b.Property("TerramorphaMode") + .HasColumnType("text"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Affinity"); + + b.HasIndex("CardType"); + + b.HasIndex("Name"); + + b.HasIndex("Rarity"); + + b.HasIndex("SetId"); + + b.HasIndex("IsPublished", "SetId"); + + b.ToTable("card_definitions", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReleaseDate") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("card_sets", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition") + .WithMany("AnimationBindings") + .HasForeignKey("CardDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardDefinition"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition") + .WithMany("Assets") + .HasForeignKey("CardDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardDefinition"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardSet", "Set") + .WithMany("Cards") + .HasForeignKey("SetId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Set"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.Navigation("AnimationBindings"); + + b.Navigation("Assets"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b => + { + b.Navigation("Cards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/20260225124936_InitialCreate.cs b/Server/src/SOR.Database/Migrations/Catalog/20260225124936_InitialCreate.cs new file mode 100644 index 0000000..53a2037 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/20260225124936_InitialCreate.cs @@ -0,0 +1,213 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SOR.Database.Migrations.Catalog +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "catalog"); + + migrationBuilder.CreateTable( + name: "card_sets", + schema: "catalog", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Code = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + ReleaseDate = table.Column(type: "date", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_card_sets", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "card_definitions", + schema: "catalog", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + CardType = table.Column(type: "text", nullable: false), + Affinity = table.Column(type: "text", nullable: false), + SpCost = table.Column(type: "integer", nullable: false), + StCost = table.Column(type: "integer", nullable: false), + other_costs = table.Column(type: "jsonb", nullable: true), + MinChannelRange = table.Column(type: "integer", nullable: true), + MaxChannelRange = table.Column(type: "integer", nullable: true), + AttackType = table.Column(type: "text", nullable: true), + RequiresLos = table.Column(type: "boolean", nullable: true), + MinAttackRange = table.Column(type: "integer", nullable: true), + MaxAttackRange = table.Column(type: "integer", nullable: true), + CanAttack = table.Column(type: "boolean", nullable: true), + Damage = table.Column(type: "integer", nullable: true), + CanDefend = table.Column(type: "boolean", nullable: true), + MaxHealth = table.Column(type: "integer", nullable: true), + MaxDefense = table.Column(type: "integer", nullable: true), + CanBeAttacked = table.Column(type: "boolean", nullable: true), + CanBeBlocked = table.Column(type: "boolean", nullable: true), + CanMove = table.Column(type: "boolean", nullable: true), + MovementType = table.Column(type: "text", nullable: true), + MovementPoints = table.Column(type: "integer", nullable: true), + CanBeObstructed = table.Column(type: "boolean", nullable: true), + CanUseAbility = table.Column(type: "boolean", nullable: true), + Genus = table.Column(type: "text[]", nullable: true), + CanBeSacrificed = table.Column(type: "boolean", nullable: true), + Tier = table.Column(type: "integer", nullable: true), + TerramorphaMode = table.Column(type: "text", nullable: true), + abilities = table.Column(type: "jsonb", nullable: true), + effects = table.Column(type: "jsonb", nullable: true), + Rarity = table.Column(type: "text", nullable: false), + SetId = table.Column(type: "uuid", nullable: true), + CollectorNumber = table.Column(type: "integer", nullable: true), + IsPublished = table.Column(type: "boolean", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_card_definitions", x => x.Id); + table.ForeignKey( + name: "FK_card_definitions_card_sets_SetId", + column: x => x.SetId, + principalSchema: "catalog", + principalTable: "card_sets", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.CreateTable( + name: "card_animation_bindings", + schema: "catalog", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CardDefinitionId = table.Column(type: "uuid", nullable: false), + ActionName = table.Column(type: "text", nullable: false), + AnimationCdnUrl = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_card_animation_bindings", x => x.Id); + table.ForeignKey( + name: "FK_card_animation_bindings_card_definitions_CardDefinitionId", + column: x => x.CardDefinitionId, + principalSchema: "catalog", + principalTable: "card_definitions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "card_assets", + schema: "catalog", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CardDefinitionId = table.Column(type: "uuid", nullable: false), + AssetType = table.Column(type: "text", nullable: false), + CdnUrl = table.Column(type: "text", nullable: false), + MimeType = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_card_assets", x => x.Id); + table.ForeignKey( + name: "FK_card_assets_card_definitions_CardDefinitionId", + column: x => x.CardDefinitionId, + principalSchema: "catalog", + principalTable: "card_definitions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_card_animation_bindings_CardDefinitionId_ActionName", + schema: "catalog", + table: "card_animation_bindings", + columns: new[] { "CardDefinitionId", "ActionName" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_card_assets_CardDefinitionId_AssetType", + schema: "catalog", + table: "card_assets", + columns: new[] { "CardDefinitionId", "AssetType" }); + + migrationBuilder.CreateIndex( + name: "IX_card_definitions_Affinity", + schema: "catalog", + table: "card_definitions", + column: "Affinity"); + + migrationBuilder.CreateIndex( + name: "IX_card_definitions_CardType", + schema: "catalog", + table: "card_definitions", + column: "CardType"); + + migrationBuilder.CreateIndex( + name: "IX_card_definitions_IsPublished_SetId", + schema: "catalog", + table: "card_definitions", + columns: new[] { "IsPublished", "SetId" }); + + migrationBuilder.CreateIndex( + name: "IX_card_definitions_Name", + schema: "catalog", + table: "card_definitions", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_card_definitions_Rarity", + schema: "catalog", + table: "card_definitions", + column: "Rarity"); + + migrationBuilder.CreateIndex( + name: "IX_card_definitions_SetId", + schema: "catalog", + table: "card_definitions", + column: "SetId"); + + migrationBuilder.CreateIndex( + name: "IX_card_sets_Code", + schema: "catalog", + table: "card_sets", + column: "Code", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "card_animation_bindings", + schema: "catalog"); + + migrationBuilder.DropTable( + name: "card_assets", + schema: "catalog"); + + migrationBuilder.DropTable( + name: "card_definitions", + schema: "catalog"); + + migrationBuilder.DropTable( + name: "card_sets", + schema: "catalog"); + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs b/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs new file mode 100644 index 0000000..781e8dd --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Catalog/CatalogDbContextModelSnapshot.cs @@ -0,0 +1,300 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Catalog +{ + [DbContext(typeof(CatalogDbContext))] + partial class CatalogDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("catalog") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActionName") + .IsRequired() + .HasColumnType("text"); + + b.Property("AnimationCdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CardDefinitionId", "ActionName") + .IsUnique(); + + b.ToTable("card_animation_bindings", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AssetType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CdnUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MimeType") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CardDefinitionId", "AssetType"); + + b.ToTable("card_assets", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AbilitiesJson") + .HasColumnType("jsonb") + .HasColumnName("abilities"); + + b.Property("Affinity") + .IsRequired() + .HasColumnType("text"); + + b.Property("AttackType") + .HasColumnType("text"); + + b.Property("CanAttack") + .HasColumnType("boolean"); + + b.Property("CanBeAttacked") + .HasColumnType("boolean"); + + b.Property("CanBeBlocked") + .HasColumnType("boolean"); + + b.Property("CanBeObstructed") + .HasColumnType("boolean"); + + b.Property("CanBeSacrificed") + .HasColumnType("boolean"); + + b.Property("CanDefend") + .HasColumnType("boolean"); + + b.Property("CanMove") + .HasColumnType("boolean"); + + b.Property("CanUseAbility") + .HasColumnType("boolean"); + + b.Property("CardType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CollectorNumber") + .HasColumnType("integer"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Damage") + .HasColumnType("integer"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("EffectsJson") + .HasColumnType("jsonb") + .HasColumnName("effects"); + + b.Property("Genus") + .HasColumnType("text[]"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("MaxAttackRange") + .HasColumnType("integer"); + + b.Property("MaxChannelRange") + .HasColumnType("integer"); + + b.Property("MaxDefense") + .HasColumnType("integer"); + + b.Property("MaxHealth") + .HasColumnType("integer"); + + b.Property("MinAttackRange") + .HasColumnType("integer"); + + b.Property("MinChannelRange") + .HasColumnType("integer"); + + b.Property("MovementPoints") + .HasColumnType("integer"); + + b.Property("MovementType") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OtherCostsJson") + .HasColumnType("jsonb") + .HasColumnName("other_costs"); + + b.Property("Rarity") + .IsRequired() + .HasColumnType("text"); + + b.Property("RequiresLos") + .HasColumnType("boolean"); + + b.Property("SetId") + .HasColumnType("uuid"); + + b.Property("SpCost") + .HasColumnType("integer"); + + b.Property("StCost") + .HasColumnType("integer"); + + b.Property("TerramorphaMode") + .HasColumnType("text"); + + b.Property("Tier") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Affinity"); + + b.HasIndex("CardType"); + + b.HasIndex("Name"); + + b.HasIndex("Rarity"); + + b.HasIndex("SetId"); + + b.HasIndex("IsPublished", "SetId"); + + b.ToTable("card_definitions", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReleaseDate") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("card_sets", "catalog"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition") + .WithMany("AnimationBindings") + .HasForeignKey("CardDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardDefinition"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition") + .WithMany("Assets") + .HasForeignKey("CardDefinitionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CardDefinition"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.HasOne("SOR.Database.Entities.Catalog.CardSet", "Set") + .WithMany("Cards") + .HasForeignKey("SetId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Set"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b => + { + b.Navigation("AnimationBindings"); + + b.Navigation("Assets"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b => + { + b.Navigation("Cards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Chat/20260225124946_InitialCreate.Designer.cs b/Server/src/SOR.Database/Migrations/Chat/20260225124946_InitialCreate.Designer.cs new file mode 100644 index 0000000..b2233dd --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Chat/20260225124946_InitialCreate.Designer.cs @@ -0,0 +1,151 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Chat +{ + [DbContext(typeof(ChatDbContext))] + [Migration("20260225124946_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("chat") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ChannelType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MatchId") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ChannelType"); + + b.HasIndex("MatchId"); + + b.ToTable("channels", "chat"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("ChannelId") + .HasColumnType("uuid"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LeftAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("ChannelId", "AccountId") + .IsUnique(); + + b.ToTable("members", "chat"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ChannelId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("EditedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("SenderAccountId") + .HasColumnType("uuid"); + + b.Property("SentAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("SenderAccountId"); + + b.HasIndex("ChannelId", "SentAt"); + + b.ToTable("messages", "chat"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMember", b => + { + b.HasOne("SOR.Database.Entities.Chat.ChatChannel", "Channel") + .WithMany("Members") + .HasForeignKey("ChannelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Channel"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMessage", b => + { + b.HasOne("SOR.Database.Entities.Chat.ChatChannel", "Channel") + .WithMany("Messages") + .HasForeignKey("ChannelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Channel"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatChannel", b => + { + b.Navigation("Members"); + + b.Navigation("Messages"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Chat/20260225124946_InitialCreate.cs b/Server/src/SOR.Database/Migrations/Chat/20260225124946_InitialCreate.cs new file mode 100644 index 0000000..29895f1 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Chat/20260225124946_InitialCreate.cs @@ -0,0 +1,135 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SOR.Database.Migrations.Chat +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "chat"); + + migrationBuilder.CreateTable( + name: "channels", + schema: "chat", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + ChannelType = table.Column(type: "text", nullable: false), + MatchId = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_channels", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "members", + schema: "chat", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ChannelId = table.Column(type: "uuid", nullable: false), + AccountId = table.Column(type: "uuid", nullable: false), + JoinedAt = table.Column(type: "timestamp with time zone", nullable: false), + LeftAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_members", x => x.Id); + table.ForeignKey( + name: "FK_members_channels_ChannelId", + column: x => x.ChannelId, + principalSchema: "chat", + principalTable: "channels", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "messages", + schema: "chat", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ChannelId = table.Column(type: "uuid", nullable: false), + SenderAccountId = table.Column(type: "uuid", nullable: false), + Content = table.Column(type: "text", nullable: false), + SentAt = table.Column(type: "timestamp with time zone", nullable: false), + EditedAt = table.Column(type: "timestamp with time zone", nullable: true), + IsDeleted = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_messages", x => x.Id); + table.ForeignKey( + name: "FK_messages_channels_ChannelId", + column: x => x.ChannelId, + principalSchema: "chat", + principalTable: "channels", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_channels_ChannelType", + schema: "chat", + table: "channels", + column: "ChannelType"); + + migrationBuilder.CreateIndex( + name: "IX_channels_MatchId", + schema: "chat", + table: "channels", + column: "MatchId"); + + migrationBuilder.CreateIndex( + name: "IX_members_AccountId", + schema: "chat", + table: "members", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_members_ChannelId_AccountId", + schema: "chat", + table: "members", + columns: new[] { "ChannelId", "AccountId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_messages_ChannelId_SentAt", + schema: "chat", + table: "messages", + columns: new[] { "ChannelId", "SentAt" }); + + migrationBuilder.CreateIndex( + name: "IX_messages_SenderAccountId", + schema: "chat", + table: "messages", + column: "SenderAccountId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "members", + schema: "chat"); + + migrationBuilder.DropTable( + name: "messages", + schema: "chat"); + + migrationBuilder.DropTable( + name: "channels", + schema: "chat"); + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Chat/ChatDbContextModelSnapshot.cs b/Server/src/SOR.Database/Migrations/Chat/ChatDbContextModelSnapshot.cs new file mode 100644 index 0000000..838d122 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Chat/ChatDbContextModelSnapshot.cs @@ -0,0 +1,148 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Chat +{ + [DbContext(typeof(ChatDbContext))] + partial class ChatDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("chat") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ChannelType") + .IsRequired() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MatchId") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ChannelType"); + + b.HasIndex("MatchId"); + + b.ToTable("channels", "chat"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMember", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("ChannelId") + .HasColumnType("uuid"); + + b.Property("JoinedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LeftAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("ChannelId", "AccountId") + .IsUnique(); + + b.ToTable("members", "chat"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ChannelId") + .HasColumnType("uuid"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("EditedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsDeleted") + .HasColumnType("boolean"); + + b.Property("SenderAccountId") + .HasColumnType("uuid"); + + b.Property("SentAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("SenderAccountId"); + + b.HasIndex("ChannelId", "SentAt"); + + b.ToTable("messages", "chat"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMember", b => + { + b.HasOne("SOR.Database.Entities.Chat.ChatChannel", "Channel") + .WithMany("Members") + .HasForeignKey("ChannelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Channel"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatMessage", b => + { + b.HasOne("SOR.Database.Entities.Chat.ChatChannel", "Channel") + .WithMany("Messages") + .HasForeignKey("ChannelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Channel"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Chat.ChatChannel", b => + { + b.Navigation("Members"); + + b.Navigation("Messages"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Collection/20260225124939_InitialCreate.Designer.cs b/Server/src/SOR.Database/Migrations/Collection/20260225124939_InitialCreate.Designer.cs new file mode 100644 index 0000000..7723c44 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Collection/20260225124939_InitialCreate.Designer.cs @@ -0,0 +1,135 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Collection +{ + [DbContext(typeof(CollectionDbContext))] + [Migration("20260225124939_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("collection") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Collection.Deck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("ArchSpiritCardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsValid") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.ToTable("decks", "collection"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Collection.DeckCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("DeckId") + .HasColumnType("uuid"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("DeckId", "CardDefinitionId") + .IsUnique(); + + b.ToTable("deck_cards", "collection"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Collection.PlayerCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AcquiredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("IsFoil") + .HasColumnType("boolean"); + + b.Property("SerialNumber") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("AccountId", "CardDefinitionId"); + + b.ToTable("player_cards", "collection"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Collection.DeckCard", b => + { + b.HasOne("SOR.Database.Entities.Collection.Deck", "Deck") + .WithMany("Cards") + .HasForeignKey("DeckId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Deck"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Collection.Deck", b => + { + b.Navigation("Cards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Collection/20260225124939_InitialCreate.cs b/Server/src/SOR.Database/Migrations/Collection/20260225124939_InitialCreate.cs new file mode 100644 index 0000000..2dfc662 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Collection/20260225124939_InitialCreate.cs @@ -0,0 +1,117 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SOR.Database.Migrations.Collection +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "collection"); + + migrationBuilder.CreateTable( + name: "decks", + schema: "collection", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + AccountId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + ArchSpiritCardDefinitionId = table.Column(type: "uuid", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false), + IsValid = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_decks", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "player_cards", + schema: "collection", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + AccountId = table.Column(type: "uuid", nullable: false), + CardDefinitionId = table.Column(type: "uuid", nullable: false), + AcquiredAt = table.Column(type: "timestamp with time zone", nullable: false), + IsFoil = table.Column(type: "boolean", nullable: false), + SerialNumber = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_player_cards", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "deck_cards", + schema: "collection", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + DeckId = table.Column(type: "uuid", nullable: false), + CardDefinitionId = table.Column(type: "uuid", nullable: false), + Quantity = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_deck_cards", x => x.Id); + table.ForeignKey( + name: "FK_deck_cards_decks_DeckId", + column: x => x.DeckId, + principalSchema: "collection", + principalTable: "decks", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_deck_cards_DeckId_CardDefinitionId", + schema: "collection", + table: "deck_cards", + columns: new[] { "DeckId", "CardDefinitionId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_decks_AccountId", + schema: "collection", + table: "decks", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_player_cards_AccountId", + schema: "collection", + table: "player_cards", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_player_cards_AccountId_CardDefinitionId", + schema: "collection", + table: "player_cards", + columns: new[] { "AccountId", "CardDefinitionId" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "deck_cards", + schema: "collection"); + + migrationBuilder.DropTable( + name: "player_cards", + schema: "collection"); + + migrationBuilder.DropTable( + name: "decks", + schema: "collection"); + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Collection/CollectionDbContextModelSnapshot.cs b/Server/src/SOR.Database/Migrations/Collection/CollectionDbContextModelSnapshot.cs new file mode 100644 index 0000000..9a973e3 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Collection/CollectionDbContextModelSnapshot.cs @@ -0,0 +1,132 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Collection +{ + [DbContext(typeof(CollectionDbContext))] + partial class CollectionDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("collection") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SOR.Database.Entities.Collection.Deck", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("ArchSpiritCardDefinitionId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsValid") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.ToTable("decks", "collection"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Collection.DeckCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("DeckId") + .HasColumnType("uuid"); + + b.Property("Quantity") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("DeckId", "CardDefinitionId") + .IsUnique(); + + b.ToTable("deck_cards", "collection"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Collection.PlayerCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("AcquiredAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CardDefinitionId") + .HasColumnType("uuid"); + + b.Property("IsFoil") + .HasColumnType("boolean"); + + b.Property("SerialNumber") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("AccountId", "CardDefinitionId"); + + b.ToTable("player_cards", "collection"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Collection.DeckCard", b => + { + b.HasOne("SOR.Database.Entities.Collection.Deck", "Deck") + .WithMany("Cards") + .HasForeignKey("DeckId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Deck"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Collection.Deck", b => + { + b.Navigation("Cards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Identity/20260225124925_InitialCreate.Designer.cs b/Server/src/SOR.Database/Migrations/Identity/20260225124925_InitialCreate.Designer.cs new file mode 100644 index 0000000..cd34f89 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Identity/20260225124925_InitialCreate.Designer.cs @@ -0,0 +1,332 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Identity +{ + [DbContext(typeof(SorIdentityDbContext))] + [Migration("20260225124925_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("identity") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("roles", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("role_claims", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("account_claims", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("external_logins", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("account_roles", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("account_tokens", "identity"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Identity.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("AvatarCdnUrl") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastLoginAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("DisplayName"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("accounts", "identity"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Identity.AccountSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeviceId") + .HasColumnType("text"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IpAddress") + .HasColumnType("text"); + + b.Property("RevokedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserAgent") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("AccountId", "ExpiresAt"); + + b.ToTable("account_sessions", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("SOR.Database.Entities.Identity.Account", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("SOR.Database.Entities.Identity.Account", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SOR.Database.Entities.Identity.Account", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("SOR.Database.Entities.Identity.Account", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Identity/20260225124925_InitialCreate.cs b/Server/src/SOR.Database/Migrations/Identity/20260225124925_InitialCreate.cs new file mode 100644 index 0000000..fd98ba0 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Identity/20260225124925_InitialCreate.cs @@ -0,0 +1,300 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace SOR.Database.Migrations.Identity +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "identity"); + + migrationBuilder.CreateTable( + name: "account_sessions", + schema: "identity", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + AccountId = table.Column(type: "uuid", nullable: false), + TokenHash = table.Column(type: "text", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + ExpiresAt = table.Column(type: "timestamp with time zone", nullable: false), + RevokedAt = table.Column(type: "timestamp with time zone", nullable: true), + IpAddress = table.Column(type: "text", nullable: true), + UserAgent = table.Column(type: "text", nullable: true), + DeviceId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_account_sessions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "accounts", + schema: "identity", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + DisplayName = table.Column(type: "text", nullable: true), + AvatarCdnUrl = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + LastLoginAt = table.Column(type: "timestamp with time zone", nullable: true), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_accounts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "roles", + schema: "identity", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_roles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "account_claims", + schema: "identity", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_account_claims", x => x.Id); + table.ForeignKey( + name: "FK_account_claims_accounts_UserId", + column: x => x.UserId, + principalSchema: "identity", + principalTable: "accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "account_tokens", + schema: "identity", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_account_tokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_account_tokens_accounts_UserId", + column: x => x.UserId, + principalSchema: "identity", + principalTable: "accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "external_logins", + schema: "identity", + columns: table => new + { + LoginProvider = table.Column(type: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_external_logins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_external_logins_accounts_UserId", + column: x => x.UserId, + principalSchema: "identity", + principalTable: "accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "account_roles", + schema: "identity", + columns: table => new + { + UserId = table.Column(type: "uuid", nullable: false), + RoleId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_account_roles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_account_roles_accounts_UserId", + column: x => x.UserId, + principalSchema: "identity", + principalTable: "accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_account_roles_roles_RoleId", + column: x => x.RoleId, + principalSchema: "identity", + principalTable: "roles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "role_claims", + schema: "identity", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_role_claims", x => x.Id); + table.ForeignKey( + name: "FK_role_claims_roles_RoleId", + column: x => x.RoleId, + principalSchema: "identity", + principalTable: "roles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_account_claims_UserId", + schema: "identity", + table: "account_claims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_account_roles_RoleId", + schema: "identity", + table: "account_roles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_account_sessions_AccountId_ExpiresAt", + schema: "identity", + table: "account_sessions", + columns: new[] { "AccountId", "ExpiresAt" }); + + migrationBuilder.CreateIndex( + name: "IX_account_sessions_TokenHash", + schema: "identity", + table: "account_sessions", + column: "TokenHash", + unique: true); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + schema: "identity", + table: "accounts", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_accounts_DisplayName", + schema: "identity", + table: "accounts", + column: "DisplayName"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + schema: "identity", + table: "accounts", + column: "NormalizedUserName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_external_logins_UserId", + schema: "identity", + table: "external_logins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_role_claims_RoleId", + schema: "identity", + table: "role_claims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + schema: "identity", + table: "roles", + column: "NormalizedName", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "account_claims", + schema: "identity"); + + migrationBuilder.DropTable( + name: "account_roles", + schema: "identity"); + + migrationBuilder.DropTable( + name: "account_sessions", + schema: "identity"); + + migrationBuilder.DropTable( + name: "account_tokens", + schema: "identity"); + + migrationBuilder.DropTable( + name: "external_logins", + schema: "identity"); + + migrationBuilder.DropTable( + name: "role_claims", + schema: "identity"); + + migrationBuilder.DropTable( + name: "accounts", + schema: "identity"); + + migrationBuilder.DropTable( + name: "roles", + schema: "identity"); + } + } +} diff --git a/Server/src/SOR.Database/Migrations/Identity/SorIdentityDbContextModelSnapshot.cs b/Server/src/SOR.Database/Migrations/Identity/SorIdentityDbContextModelSnapshot.cs new file mode 100644 index 0000000..bb5fb13 --- /dev/null +++ b/Server/src/SOR.Database/Migrations/Identity/SorIdentityDbContextModelSnapshot.cs @@ -0,0 +1,329 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SOR.Database.Contexts; + +#nullable disable + +namespace SOR.Database.Migrations.Identity +{ + [DbContext(typeof(SorIdentityDbContext))] + partial class SorIdentityDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("identity") + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("roles", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("role_claims", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("account_claims", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("external_logins", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("RoleId") + .HasColumnType("uuid"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("account_roles", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("account_tokens", "identity"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Identity.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("AvatarCdnUrl") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LastLoginAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("DisplayName"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("accounts", "identity"); + }); + + modelBuilder.Entity("SOR.Database.Entities.Identity.AccountSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccountId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeviceId") + .HasColumnType("text"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IpAddress") + .HasColumnType("text"); + + b.Property("RevokedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenHash") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserAgent") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("AccountId", "ExpiresAt"); + + b.ToTable("account_sessions", "identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("SOR.Database.Entities.Identity.Account", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("SOR.Database.Entities.Identity.Account", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SOR.Database.Entities.Identity.Account", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("SOR.Database.Entities.Identity.Account", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +}