Add EF Core migrations and SuperAdmin seeder

- 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 <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-02-25 07:52:30 -05:00
co-authored by Claude Happy
parent ee2891d38e
commit 6f9ed0668f
16 changed files with 3017 additions and 0 deletions
+36
View File
@@ -125,4 +125,40 @@ app.MapRazorPages();
app.MapRazorComponents<App>()
.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<RoleManager<IdentityRole<Guid>>>();
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<Account>>();
var cfg = scope.ServiceProvider.GetRequiredService<IConfiguration>();
foreach (var role in new[] { "SuperAdmin", "Admin" })
{
if (!await roleManager.RoleExistsAsync(role))
await roleManager.CreateAsync(new IdentityRole<Guid>(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");
}
}
@@ -0,0 +1,135 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset>("ListedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ListingType")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("PlayerCardId")
.HasColumnType("uuid");
b.Property<decimal>("Price")
.HasColumnType("numeric(18,4)");
b.Property<Guid>("SellerAccountId")
.HasColumnType("uuid");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<decimal>("Amount")
.HasColumnType("numeric(18,4)");
b.Property<Guid>("BuyerAccountId")
.HasColumnType("uuid");
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ListingId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerCardId")
.HasColumnType("uuid");
b.Property<Guid>("SellerAccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("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
}
}
}
@@ -0,0 +1,119 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Bazaar
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "bazaar");
migrationBuilder.CreateTable(
name: "listings",
schema: "bazaar",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
SellerAccountId = table.Column<Guid>(type: "uuid", nullable: false),
PlayerCardId = table.Column<Guid>(type: "uuid", nullable: false),
CardDefinitionId = table.Column<Guid>(type: "uuid", nullable: false),
ListingType = table.Column<string>(type: "text", nullable: false),
Price = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
Currency = table.Column<string>(type: "text", nullable: false),
ListedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
ExpiresAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Status = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
ListingId = table.Column<Guid>(type: "uuid", nullable: false),
BuyerAccountId = table.Column<Guid>(type: "uuid", nullable: false),
SellerAccountId = table.Column<Guid>(type: "uuid", nullable: false),
PlayerCardId = table.Column<Guid>(type: "uuid", nullable: false),
Amount = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
Currency = table.Column<string>(type: "text", nullable: false),
TransactedAt = table.Column<DateTimeOffset>(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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "transactions",
schema: "bazaar");
migrationBuilder.DropTable(
name: "listings",
schema: "bazaar");
}
}
}
@@ -0,0 +1,132 @@
// <auto-generated />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset>("ListedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("ListingType")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("PlayerCardId")
.HasColumnType("uuid");
b.Property<decimal>("Price")
.HasColumnType("numeric(18,4)");
b.Property<Guid>("SellerAccountId")
.HasColumnType("uuid");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<decimal>("Amount")
.HasColumnType("numeric(18,4)");
b.Property<Guid>("BuyerAccountId")
.HasColumnType("uuid");
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ListingId")
.HasColumnType("uuid");
b.Property<Guid>("PlayerCardId")
.HasColumnType("uuid");
b.Property<Guid>("SellerAccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("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
}
}
}
@@ -0,0 +1,303 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ActionName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AnimationCdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AssetType")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("CdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AbilitiesJson")
.HasColumnType("jsonb")
.HasColumnName("abilities");
b.Property<string>("Affinity")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AttackType")
.HasColumnType("text");
b.Property<bool?>("CanAttack")
.HasColumnType("boolean");
b.Property<bool?>("CanBeAttacked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeBlocked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeObstructed")
.HasColumnType("boolean");
b.Property<bool?>("CanBeSacrificed")
.HasColumnType("boolean");
b.Property<bool?>("CanDefend")
.HasColumnType("boolean");
b.Property<bool?>("CanMove")
.HasColumnType("boolean");
b.Property<bool?>("CanUseAbility")
.HasColumnType("boolean");
b.Property<string>("CardType")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("CollectorNumber")
.HasColumnType("integer");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("Damage")
.HasColumnType("integer");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EffectsJson")
.HasColumnType("jsonb")
.HasColumnName("effects");
b.Property<string[]>("Genus")
.HasColumnType("text[]");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<int?>("MaxAttackRange")
.HasColumnType("integer");
b.Property<int?>("MaxChannelRange")
.HasColumnType("integer");
b.Property<int?>("MaxDefense")
.HasColumnType("integer");
b.Property<int?>("MaxHealth")
.HasColumnType("integer");
b.Property<int?>("MinAttackRange")
.HasColumnType("integer");
b.Property<int?>("MinChannelRange")
.HasColumnType("integer");
b.Property<int?>("MovementPoints")
.HasColumnType("integer");
b.Property<string>("MovementType")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OtherCostsJson")
.HasColumnType("jsonb")
.HasColumnName("other_costs");
b.Property<string>("Rarity")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("RequiresLos")
.HasColumnType("boolean");
b.Property<Guid?>("SetId")
.HasColumnType("uuid");
b.Property<int>("SpCost")
.HasColumnType("integer");
b.Property<int>("StCost")
.HasColumnType("integer");
b.Property<string>("TerramorphaMode")
.HasColumnType("text");
b.Property<int?>("Tier")
.HasColumnType("integer");
b.Property<DateTimeOffset>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateOnly?>("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
}
}
}
@@ -0,0 +1,213 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Catalog
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "catalog");
migrationBuilder.CreateTable(
name: "card_sets",
schema: "catalog",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Code = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
ReleaseDate = table.Column<DateOnly>(type: "date", nullable: true),
IsActive = table.Column<bool>(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<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
CardType = table.Column<string>(type: "text", nullable: false),
Affinity = table.Column<string>(type: "text", nullable: false),
SpCost = table.Column<int>(type: "integer", nullable: false),
StCost = table.Column<int>(type: "integer", nullable: false),
other_costs = table.Column<string>(type: "jsonb", nullable: true),
MinChannelRange = table.Column<int>(type: "integer", nullable: true),
MaxChannelRange = table.Column<int>(type: "integer", nullable: true),
AttackType = table.Column<string>(type: "text", nullable: true),
RequiresLos = table.Column<bool>(type: "boolean", nullable: true),
MinAttackRange = table.Column<int>(type: "integer", nullable: true),
MaxAttackRange = table.Column<int>(type: "integer", nullable: true),
CanAttack = table.Column<bool>(type: "boolean", nullable: true),
Damage = table.Column<int>(type: "integer", nullable: true),
CanDefend = table.Column<bool>(type: "boolean", nullable: true),
MaxHealth = table.Column<int>(type: "integer", nullable: true),
MaxDefense = table.Column<int>(type: "integer", nullable: true),
CanBeAttacked = table.Column<bool>(type: "boolean", nullable: true),
CanBeBlocked = table.Column<bool>(type: "boolean", nullable: true),
CanMove = table.Column<bool>(type: "boolean", nullable: true),
MovementType = table.Column<string>(type: "text", nullable: true),
MovementPoints = table.Column<int>(type: "integer", nullable: true),
CanBeObstructed = table.Column<bool>(type: "boolean", nullable: true),
CanUseAbility = table.Column<bool>(type: "boolean", nullable: true),
Genus = table.Column<string[]>(type: "text[]", nullable: true),
CanBeSacrificed = table.Column<bool>(type: "boolean", nullable: true),
Tier = table.Column<int>(type: "integer", nullable: true),
TerramorphaMode = table.Column<string>(type: "text", nullable: true),
abilities = table.Column<string>(type: "jsonb", nullable: true),
effects = table.Column<string>(type: "jsonb", nullable: true),
Rarity = table.Column<string>(type: "text", nullable: false),
SetId = table.Column<Guid>(type: "uuid", nullable: true),
CollectorNumber = table.Column<int>(type: "integer", nullable: true),
IsPublished = table.Column<bool>(type: "boolean", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(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<Guid>(type: "uuid", nullable: false),
CardDefinitionId = table.Column<Guid>(type: "uuid", nullable: false),
ActionName = table.Column<string>(type: "text", nullable: false),
AnimationCdnUrl = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
CardDefinitionId = table.Column<Guid>(type: "uuid", nullable: false),
AssetType = table.Column<string>(type: "text", nullable: false),
CdnUrl = table.Column<string>(type: "text", nullable: false),
MimeType = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(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);
}
/// <inheritdoc />
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");
}
}
}
@@ -0,0 +1,300 @@
// <auto-generated />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ActionName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AnimationCdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AssetType")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("CdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AbilitiesJson")
.HasColumnType("jsonb")
.HasColumnName("abilities");
b.Property<string>("Affinity")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AttackType")
.HasColumnType("text");
b.Property<bool?>("CanAttack")
.HasColumnType("boolean");
b.Property<bool?>("CanBeAttacked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeBlocked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeObstructed")
.HasColumnType("boolean");
b.Property<bool?>("CanBeSacrificed")
.HasColumnType("boolean");
b.Property<bool?>("CanDefend")
.HasColumnType("boolean");
b.Property<bool?>("CanMove")
.HasColumnType("boolean");
b.Property<bool?>("CanUseAbility")
.HasColumnType("boolean");
b.Property<string>("CardType")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("CollectorNumber")
.HasColumnType("integer");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("Damage")
.HasColumnType("integer");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EffectsJson")
.HasColumnType("jsonb")
.HasColumnName("effects");
b.Property<string[]>("Genus")
.HasColumnType("text[]");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<int?>("MaxAttackRange")
.HasColumnType("integer");
b.Property<int?>("MaxChannelRange")
.HasColumnType("integer");
b.Property<int?>("MaxDefense")
.HasColumnType("integer");
b.Property<int?>("MaxHealth")
.HasColumnType("integer");
b.Property<int?>("MinAttackRange")
.HasColumnType("integer");
b.Property<int?>("MinChannelRange")
.HasColumnType("integer");
b.Property<int?>("MovementPoints")
.HasColumnType("integer");
b.Property<string>("MovementType")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OtherCostsJson")
.HasColumnType("jsonb")
.HasColumnName("other_costs");
b.Property<string>("Rarity")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("RequiresLos")
.HasColumnType("boolean");
b.Property<Guid?>("SetId")
.HasColumnType("uuid");
b.Property<int>("SpCost")
.HasColumnType("integer");
b.Property<int>("StCost")
.HasColumnType("integer");
b.Property<string>("TerramorphaMode")
.HasColumnType("text");
b.Property<int?>("Tier")
.HasColumnType("integer");
b.Property<DateTimeOffset>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateOnly?>("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
}
}
}
@@ -0,0 +1,151 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ChannelType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("MatchId")
.HasColumnType("text");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<Guid>("ChannelId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("JoinedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ChannelId")
.HasColumnType("uuid");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("EditedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<Guid>("SenderAccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("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
}
}
}
@@ -0,0 +1,135 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Chat
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "chat");
migrationBuilder.CreateTable(
name: "channels",
schema: "chat",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
ChannelType = table.Column<string>(type: "text", nullable: false),
MatchId = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(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<Guid>(type: "uuid", nullable: false),
ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
AccountId = table.Column<Guid>(type: "uuid", nullable: false),
JoinedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
LeftAt = table.Column<DateTimeOffset>(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<Guid>(type: "uuid", nullable: false),
ChannelId = table.Column<Guid>(type: "uuid", nullable: false),
SenderAccountId = table.Column<Guid>(type: "uuid", nullable: false),
Content = table.Column<string>(type: "text", nullable: false),
SentAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
EditedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
IsDeleted = table.Column<bool>(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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "members",
schema: "chat");
migrationBuilder.DropTable(
name: "messages",
schema: "chat");
migrationBuilder.DropTable(
name: "channels",
schema: "chat");
}
}
}
@@ -0,0 +1,148 @@
// <auto-generated />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ChannelType")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("MatchId")
.HasColumnType("text");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<Guid>("ChannelId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("JoinedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateTimeOffset?>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("ChannelId")
.HasColumnType("uuid");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset?>("EditedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<Guid>("SenderAccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("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
}
}
}
@@ -0,0 +1,135 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<Guid>("ArchSpiritCardDefinitionId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsValid")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<Guid>("DeckId")
.HasColumnType("uuid");
b.Property<int>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("AcquiredAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<bool>("IsFoil")
.HasColumnType("boolean");
b.Property<int?>("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
}
}
}
@@ -0,0 +1,117 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Collection
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "collection");
migrationBuilder.CreateTable(
name: "decks",
schema: "collection",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
AccountId = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
ArchSpiritCardDefinitionId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
IsValid = table.Column<bool>(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<Guid>(type: "uuid", nullable: false),
AccountId = table.Column<Guid>(type: "uuid", nullable: false),
CardDefinitionId = table.Column<Guid>(type: "uuid", nullable: false),
AcquiredAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
IsFoil = table.Column<bool>(type: "boolean", nullable: false),
SerialNumber = table.Column<int>(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<Guid>(type: "uuid", nullable: false),
DeckId = table.Column<Guid>(type: "uuid", nullable: false),
CardDefinitionId = table.Column<Guid>(type: "uuid", nullable: false),
Quantity = table.Column<int>(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" });
}
/// <inheritdoc />
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");
}
}
}
@@ -0,0 +1,132 @@
// <auto-generated />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<Guid>("ArchSpiritCardDefinitionId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsValid")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<Guid>("DeckId")
.HasColumnType("uuid");
b.Property<int>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("AcquiredAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<bool>("IsFoil")
.HasColumnType("boolean");
b.Property<int?>("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
}
}
}
@@ -0,0 +1,332 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("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<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("role_claims", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("account_claims", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("external_logins", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("account_roles", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("account_tokens", "identity");
});
modelBuilder.Entity("SOR.Database.Entities.Identity.Account", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("AvatarCdnUrl")
.HasColumnType("text");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DisplayName")
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LastLoginAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeviceId")
.HasColumnType("text");
b.Property<DateTimeOffset>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("IpAddress")
.HasColumnType("text");
b.Property<DateTimeOffset?>("RevokedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("TokenHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", 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<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,300 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace SOR.Database.Migrations.Identity
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "identity");
migrationBuilder.CreateTable(
name: "account_sessions",
schema: "identity",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
AccountId = table.Column<Guid>(type: "uuid", nullable: false),
TokenHash = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
ExpiresAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
RevokedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
IpAddress = table.Column<string>(type: "text", nullable: true),
UserAgent = table.Column<string>(type: "text", nullable: true),
DeviceId = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
DisplayName = table.Column<string>(type: "text", nullable: true),
AvatarCdnUrl = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
LastLoginAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: true),
SecurityStamp = table.Column<string>(type: "text", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
PhoneNumber = table.Column<string>(type: "text", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
AccessFailedCount = table.Column<int>(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<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
ClaimType = table.Column<string>(type: "text", nullable: true),
ClaimValue = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
LoginProvider = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Value = table.Column<string>(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<string>(type: "text", nullable: false),
ProviderKey = table.Column<string>(type: "text", nullable: false),
ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
UserId = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false),
RoleId = table.Column<Guid>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RoleId = table.Column<Guid>(type: "uuid", nullable: false),
ClaimType = table.Column<string>(type: "text", nullable: true),
ClaimValue = table.Column<string>(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);
}
/// <inheritdoc />
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");
}
}
}
@@ -0,0 +1,329 @@
// <auto-generated />
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<System.Guid>", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("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<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("role_claims", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("text");
b.Property<string>("ClaimValue")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("account_claims", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("ProviderKey")
.HasColumnType("text");
b.Property<string>("ProviderDisplayName")
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("external_logins", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("account_roles", "identity");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<System.Guid>", b =>
{
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.Property<string>("LoginProvider")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("account_tokens", "identity");
});
modelBuilder.Entity("SOR.Database.Entities.Identity.Account", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("AccessFailedCount")
.HasColumnType("integer");
b.Property<string>("AvatarCdnUrl")
.HasColumnType("text");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DisplayName")
.HasColumnType("text");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LastLoginAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("LockoutEnabled")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.HasColumnType("text");
b.Property<string>("PhoneNumber")
.HasColumnType("text");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property<string>("SecurityStamp")
.HasColumnType("text");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AccountId")
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeviceId")
.HasColumnType("text");
b.Property<DateTimeOffset>("ExpiresAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("IpAddress")
.HasColumnType("text");
b.Property<DateTimeOffset?>("RevokedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("TokenHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("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<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<System.Guid>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole<System.Guid>", 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<System.Guid>", b =>
{
b.HasOne("SOR.Database.Entities.Identity.Account", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}