20260323071228_RemoveNews.cs 5.3 KB

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