- 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>
136 lines
5.2 KiB
C#
136 lines
5.2 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|