20260313180453_AddRssNewsTables.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Infrastructure.Migrations.AppDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddRssNewsTables : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "RssFeedSource",
  14. columns: table => new
  15. {
  16. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false, comment: "소스 이름"),
  19. Url = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false, comment: "RSS 피드 URL"),
  20. Description = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "소스 설명"),
  21. IntervalMinutes = table.Column<int>(type: "int", nullable: false, comment: "수집 주기 (분)"),
  22. IsActive = table.Column<bool>(type: "bit", nullable: false, comment: "활성화 여부"),
  23. LastFetchedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "마지막 수집 일시"),
  24. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "수정 일시"),
  25. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "등록 일시")
  26. },
  27. constraints: table =>
  28. {
  29. table.PrimaryKey("PK_RssFeedSource", x => x.ID);
  30. },
  31. comment: "RSS 피드 소스");
  32. migrationBuilder.CreateTable(
  33. name: "RssNewsArticle",
  34. columns: table => new
  35. {
  36. ID = table.Column<int>(type: "int", nullable: false, comment: "PK")
  37. .Annotation("SqlServer:Identity", "1, 1"),
  38. RssFeedSourceID = table.Column<int>(type: "int", nullable: false, comment: "RSS 피드 소스 FK"),
  39. Title = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false, comment: "기사 제목"),
  40. Link = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true, comment: "원본 링크"),
  41. Guid = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true, comment: "RSS GUID (중복 방지)"),
  42. Author = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true, comment: "작성자"),
  43. Description = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "요약"),
  44. Content = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "본문 (content:encoded)"),
  45. ImageUrl = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: true, comment: "썸네일 이미지 URL"),
  46. SourceName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true, comment: "출처명"),
  47. Categories = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "카테고리 (JSON 배열)"),
  48. CommentCount = table.Column<int>(type: "int", nullable: false, comment: "댓글 수"),
  49. PublishedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "발행 일시"),
  50. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, comment: "수집 일시")
  51. },
  52. constraints: table =>
  53. {
  54. table.PrimaryKey("PK_RssNewsArticle", x => x.ID);
  55. table.ForeignKey(
  56. name: "FK_RssNewsArticle_RssFeedSource_RssFeedSourceID",
  57. column: x => x.RssFeedSourceID,
  58. principalTable: "RssFeedSource",
  59. principalColumn: "ID",
  60. onDelete: ReferentialAction.Cascade);
  61. },
  62. comment: "RSS 뉴스 기사");
  63. migrationBuilder.CreateIndex(
  64. name: "IX_RssFeedSource_IsActive",
  65. table: "RssFeedSource",
  66. column: "IsActive");
  67. migrationBuilder.CreateIndex(
  68. name: "IX_RssFeedSource_Url",
  69. table: "RssFeedSource",
  70. column: "Url",
  71. unique: true);
  72. migrationBuilder.CreateIndex(
  73. name: "IX_RssNewsArticle_CreatedAt",
  74. table: "RssNewsArticle",
  75. column: "CreatedAt");
  76. migrationBuilder.CreateIndex(
  77. name: "IX_RssNewsArticle_Guid_RssFeedSourceID",
  78. table: "RssNewsArticle",
  79. columns: new[] { "Guid", "RssFeedSourceID" },
  80. unique: true,
  81. filter: "[Guid] IS NOT NULL");
  82. migrationBuilder.CreateIndex(
  83. name: "IX_RssNewsArticle_PublishedAt",
  84. table: "RssNewsArticle",
  85. column: "PublishedAt");
  86. migrationBuilder.CreateIndex(
  87. name: "IX_RssNewsArticle_RssFeedSourceID",
  88. table: "RssNewsArticle",
  89. column: "RssFeedSourceID");
  90. }
  91. /// <inheritdoc />
  92. protected override void Down(MigrationBuilder migrationBuilder)
  93. {
  94. migrationBuilder.DropTable(
  95. name: "RssNewsArticle");
  96. migrationBuilder.DropTable(
  97. name: "RssFeedSource");
  98. }
  99. }
  100. }