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