| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- #nullable disable
- namespace Infrastructure.Migrations.AppDb
- {
- /// <inheritdoc />
- public partial class AddChatRoomDomain : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "ChatBan",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
- .Annotation("SqlServer:Identity", "1, 1"),
- MemberID = table.Column<int>(type: "int", nullable: false, comment: "제재 대상 회원 ID"),
- RoomKey = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "제재 룸 키 (NULL=전체)"),
- Reason = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false, comment: "제재 사유"),
- ExpiresAt = table.Column<DateTime>(type: "datetime2", nullable: true),
- CreatedBy = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "제재 등록자"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ChatBan", x => x.ID);
- table.ForeignKey(
- name: "FK_ChatBan_Member_MemberID",
- column: x => x.MemberID,
- principalTable: "Member",
- principalColumn: "ID",
- onDelete: ReferentialAction.Restrict);
- },
- comment: "채팅 제재 (RoomKey NULL=전체, ExpiresAt NULL=무기한)");
- migrationBuilder.CreateTable(
- name: "ChatRoomConfig",
- columns: table => new
- {
- RoomKey = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false, comment: "룸 키"),
- IsActive = table.Column<bool>(type: "bit", nullable: false, comment: "활성 여부 (종목방 단계 오픈 게이트)"),
- SlowModeSeconds = table.Column<short>(type: "smallint", nullable: false, comment: "슬로우 모드 (초)"),
- Notice = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true, comment: "상단 고정 공지"),
- UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ChatRoomConfig", x => x.RoomKey);
- },
- comment: "채팅방 설정 (main | stock:{code})");
- migrationBuilder.CreateIndex(
- name: "IX_ChatBan_MemberID_ExpiresAt",
- table: "ChatBan",
- columns: new[] { "MemberID", "ExpiresAt" });
- // 메인 채팅방 시드 — 기본 오픈 + 슬로우 모드 3초 (모더레이션 완충 — d2 §⑧)
- migrationBuilder.Sql("""
- IF NOT EXISTS (SELECT 1 FROM [ChatRoomConfig] WHERE [RoomKey] = N'main')
- BEGIN
- INSERT INTO [ChatRoomConfig] ([RoomKey], [IsActive], [SlowModeSeconds], [Notice], [UpdatedAt])
- VALUES (N'main', 1, 3, NULL, GETUTCDATE());
- END
- """);
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.Sql("DELETE FROM [ChatRoomConfig] WHERE [RoomKey] = N'main'");
- migrationBuilder.DropTable(
- name: "ChatBan");
- migrationBuilder.DropTable(
- name: "ChatRoomConfig");
- }
- }
- }
|