20260420091349_AddChannelHandleHistory.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb;
  5. /// <inheritdoc />
  6. public partial class AddChannelHandleHistory : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.CreateTable(
  12. name: "ChannelHandleHistory",
  13. columns: table => new
  14. {
  15. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  16. .Annotation("SqlServer:Identity", "1, 1"),
  17. ChannelID = table.Column<int>(type: "int", nullable: false, comment: "채널 ID"),
  18. OldHandle = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "이전 핸들"),
  19. ChangedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "변경 일시")
  20. },
  21. constraints: table =>
  22. {
  23. table.PrimaryKey("PK_ChannelHandleHistory", x => x.ID);
  24. table.ForeignKey(
  25. name: "FK_ChannelHandleHistory_Channel_ChannelID",
  26. column: x => x.ChannelID,
  27. principalTable: "Channel",
  28. principalColumn: "ID",
  29. onDelete: ReferentialAction.Cascade);
  30. },
  31. comment: "채널 핸들 변경 이력");
  32. migrationBuilder.CreateIndex(
  33. name: "IX_ChannelHandleHistory_ChannelID_ChangedAt",
  34. table: "ChannelHandleHistory",
  35. columns: new[] { "ChannelID", "ChangedAt" },
  36. descending: new[] { false, true });
  37. migrationBuilder.CreateIndex(
  38. name: "IX_ChannelHandleHistory_OldHandle",
  39. table: "ChannelHandleHistory",
  40. column: "OldHandle");
  41. }
  42. /// <inheritdoc />
  43. protected override void Down(MigrationBuilder migrationBuilder)
  44. {
  45. migrationBuilder.DropTable(
  46. name: "ChannelHandleHistory");
  47. }
  48. }