using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations.AppDb
{
///
public partial class RemoveNews : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RssNewsArticle");
migrationBuilder.DropTable(
name: "RssFeedSource");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RssFeedSource",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "등록 일시"),
Description = table.Column(type: "nvarchar(max)", nullable: true, comment: "소스 설명"),
IntervalMinutes = table.Column(type: "int", nullable: false, comment: "수집 주기 (분)"),
IsActive = table.Column(type: "bit", nullable: false, comment: "활성화 여부"),
LastFetchedAt = table.Column(type: "datetime2", nullable: true, comment: "마지막 수집 일시"),
Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false, comment: "소스 이름"),
UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시"),
Url = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false, comment: "RSS 피드 URL")
},
constraints: table =>
{
table.PrimaryKey("PK_RssFeedSource", x => x.ID);
},
comment: "RSS 피드 소스");
migrationBuilder.CreateTable(
name: "RssNewsArticle",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
RssFeedSourceID = table.Column(type: "int", nullable: false, comment: "RSS 피드 소스 FK"),
Author = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true, comment: "작성자"),
Categories = table.Column(type: "nvarchar(max)", nullable: true, comment: "카테고리 (JSON 배열)"),
CommentCount = table.Column(type: "int", nullable: false, comment: "댓글 수"),
Content = table.Column(type: "nvarchar(max)", nullable: true, comment: "본문 (content:encoded)"),
CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "수집 일시"),
Description = table.Column(type: "nvarchar(max)", nullable: true, comment: "요약"),
Guid = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true, comment: "RSS GUID (중복 방지)"),
ImageUrl = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true, comment: "썸네일 이미지 URL"),
Link = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true, comment: "원본 링크"),
PublishedAt = table.Column(type: "datetime2", nullable: true, comment: "발행 일시"),
SourceName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true, comment: "출처명"),
Title = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false, comment: "기사 제목")
},
constraints: table =>
{
table.PrimaryKey("PK_RssNewsArticle", x => x.ID);
table.ForeignKey(
name: "FK_RssNewsArticle_RssFeedSource_RssFeedSourceID",
column: x => x.RssFeedSourceID,
principalTable: "RssFeedSource",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
},
comment: "RSS 뉴스 기사");
migrationBuilder.CreateIndex(
name: "IX_RssFeedSource_IsActive",
table: "RssFeedSource",
column: "IsActive");
migrationBuilder.CreateIndex(
name: "IX_RssFeedSource_Url",
table: "RssFeedSource",
column: "Url",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RssNewsArticle_CreatedAt",
table: "RssNewsArticle",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_RssNewsArticle_Guid_RssFeedSourceID",
table: "RssNewsArticle",
columns: new[] { "Guid", "RssFeedSourceID" },
unique: true,
filter: "[Guid] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_RssNewsArticle_PublishedAt",
table: "RssNewsArticle",
column: "PublishedAt");
migrationBuilder.CreateIndex(
name: "IX_RssNewsArticle_RssFeedSourceID",
table: "RssNewsArticle",
column: "RssFeedSourceID");
}
}
}