using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace bitforum.Migrations.DefaultDb
{
///
public partial class a3 : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BoardGroup",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
Code = table.Column(type: "nvarchar(70)", maxLength: 70, nullable: false, comment: "게시판 분류 주소"),
Name = table.Column(type: "nvarchar(70)", maxLength: 70, nullable: false, comment: "게시판 분류 명"),
Order = table.Column(type: "int", nullable: false, comment: "순서"),
Boards = table.Column(type: "bigint", nullable: false, comment: "게시판 수"),
Posts = table.Column(type: "bigint", nullable: false, comment: "게시글 수"),
Comments = table.Column(type: "bigint", nullable: false, comment: "댓글 수"),
UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시"),
CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "등록 일시")
},
constraints: table =>
{
table.PrimaryKey("PK_BoardGroup", x => x.ID);
});
migrationBuilder.CreateTable(
name: "Board",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
BoardGroupID = table.Column(type: "int", nullable: false, comment: "분류 ID"),
Code = table.Column(type: "nvarchar(70)", maxLength: 70, nullable: false, comment: "게시판 주소"),
Name = table.Column(type: "nvarchar(70)", maxLength: 70, nullable: false, comment: "게시판 이름"),
Order = table.Column(type: "int", nullable: false, comment: "순서"),
IsSearch = table.Column(type: "bit", nullable: false, comment: "검색 여부"),
IsActive = table.Column(type: "bit", nullable: false, comment: "사용 여부"),
Posts = table.Column(type: "int", nullable: false, comment: "게시글 수"),
Comments = table.Column(type: "int", nullable: false, comment: "댓글 수"),
UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시"),
CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "등록 일시")
},
constraints: table =>
{
table.PrimaryKey("PK_Board", x => x.ID);
table.ForeignKey(
name: "FK_Board_BoardGroup_BoardGroupID",
column: x => x.BoardGroupID,
principalTable: "BoardGroup",
principalColumn: "ID");
});
migrationBuilder.CreateTable(
name: "BoardMeta",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
BoardID = table.Column(type: "int", nullable: false, comment: "게시판 ID")
},
constraints: table =>
{
table.PrimaryKey("PK_BoardMeta", x => x.ID);
table.ForeignKey(
name: "FK_BoardMeta_Board_BoardID",
column: x => x.BoardID,
principalTable: "Board",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CommentMeta",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
BoardID = table.Column(type: "int", nullable: false, comment: "게시판 ID"),
EnableComment = table.Column(type: "bit", nullable: false, comment: "댓글 사용"),
PerPage = table.Column(type: "int", nullable: false, comment: "목록 표시"),
AllowLike = table.Column(type: "bit", nullable: false, comment: "댓글 공감 사용"),
AllowDisLike = table.Column(type: "bit", nullable: false, comment: "댓글 비공감 사용"),
ShowMemberPhoto = table.Column(type: "bit", nullable: false, comment: "회원 사진 공개"),
ShowMemberIcon = table.Column(type: "bit", nullable: false, comment: "회원 아이콘 공개"),
ContentPlaceholder = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true, comment: "안내 문구"),
MinContentLength = table.Column(type: "int", nullable: false, comment: "최소 입력 글자"),
MaxContentLength = table.Column(type: "int", nullable: false, comment: "최대 입력 글자"),
EnableEditor = table.Column(type: "bit", nullable: false, comment: "웹 에디터 사용"),
AllowSecret = table.Column(type: "bit", nullable: false, comment: "비밀글 사용"),
BlameHideCount = table.Column(type: "int", nullable: false, comment: "댓글 신고 시 숨김"),
DeleteProtectionDays = table.Column(type: "int", nullable: false, comment: "댓글 삭제 금지 기간"),
UpdateProtectionDays = table.Column(type: "int", nullable: false, comment: "댓글 수정 금지 기간"),
AllowDeleteProtection = table.Column(type: "bit", nullable: false, comment: "댓글 보호 기능 (삭제 시)"),
AllowUpdateProtection = table.Column(type: "bit", nullable: false, comment: "댓글 보호 기능 (수정 시)"),
EnableCommentUpdateLog = table.Column(type: "bit", nullable: false, comment: "댓글 변경 기록")
},
constraints: table =>
{
table.PrimaryKey("PK_CommentMeta", x => x.ID);
table.ForeignKey(
name: "FK_CommentMeta_Board_BoardID",
column: x => x.BoardID,
principalTable: "Board",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Post",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
BoardID = table.Column(type: "int", nullable: false, comment: "게시판 ID"),
MemberID = table.Column(type: "int", nullable: true, comment: "회원 ID"),
Subject = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false, comment: "제목"),
Content = table.Column(type: "nvarchar(max)", nullable: false, comment: "내용"),
SID = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "회원 SID"),
Email = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: true, comment: "회원 이메일"),
Name = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "회원 이름"),
Password = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true, comment: "게시글 비밀번호"),
IsReply = table.Column(type: "bit", nullable: false, comment: "답변 여부"),
IsSecret = table.Column(type: "bit", nullable: false, comment: "비밀글 여부"),
IsNotice = table.Column(type: "bit", nullable: false, comment: "일반 공지 여부"),
IsSpeaker = table.Column(type: "bit", nullable: false, comment: "전체 공지 여부"),
IsDeleted = table.Column(type: "bit", nullable: false, comment: "삭제 여부"),
Views = table.Column(type: "bigint", nullable: false, comment: "조회 수"),
Likes = table.Column(type: "bigint", nullable: false, comment: "좋아요"),
Dislikes = table.Column(type: "bigint", nullable: false, comment: "싫어요"),
Comments = table.Column(type: "bigint", nullable: false, comment: "댓글 수"),
Blames = table.Column(type: "bigint", nullable: false, comment: "신고 수"),
Files = table.Column(type: "smallint", nullable: false, comment: "파일 수"),
Images = table.Column(type: "smallint", nullable: false, comment: "이미지 수"),
Videos = table.Column(type: "smallint", nullable: false, comment: "동영상 수"),
Tags = table.Column(type: "smallint", nullable: false, comment: "Tag 수"),
IpAddress = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false, comment: "IP"),
UserAgent = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false, comment: "User-Agent"),
LastReplyUpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "마지막 답변 일시"),
LastCommentUpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "마지막 댓글 일시"),
DeletedAt = table.Column(type: "datetime2", nullable: true, comment: "삭제 일시"),
UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시"),
CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "등록 일시")
},
constraints: table =>
{
table.PrimaryKey("PK_Post", x => x.ID);
table.ForeignKey(
name: "FK_Post_Board_BoardID",
column: x => x.BoardID,
principalTable: "Board",
principalColumn: "ID");
table.ForeignKey(
name: "FK_Post_Member_MemberID",
column: x => x.MemberID,
principalTable: "Member",
principalColumn: "ID");
});
migrationBuilder.CreateTable(
name: "PostMeta",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
BoardID = table.Column(type: "int", nullable: false, comment: "게시판 ID")
},
constraints: table =>
{
table.PrimaryKey("PK_PostMeta", x => x.ID);
table.ForeignKey(
name: "FK_PostMeta_Board_BoardID",
column: x => x.BoardID,
principalTable: "Board",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Comment",
columns: table => new
{
ID = table.Column(type: "int", nullable: false, comment: "PK")
.Annotation("SqlServer:Identity", "1, 1"),
BoardID = table.Column(type: "int", nullable: false, comment: "게시판 ID"),
PostID = table.Column(type: "int", nullable: false, comment: "게시글 ID"),
MemberID = table.Column(type: "int", nullable: true, comment: "회원 ID"),
ParentID = table.Column(type: "int", nullable: true, comment: "부모 댓글 ID"),
Depth = table.Column(type: "int", nullable: false, comment: "댓글 깊이"),
Content = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false, comment: "댓글 내용"),
SID = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "회원 SID"),
Email = table.Column(type: "nvarchar(60)", maxLength: 60, nullable: true, comment: "회원 이메일"),
Name = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "회원 이름"),
Password = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true, comment: "댓글 비밀번호"),
IsSecret = table.Column(type: "bit", nullable: false, comment: "비밀글 여부"),
IsDeleted = table.Column(type: "bit", nullable: false, comment: "삭제 여부"),
Likes = table.Column(type: "bigint", nullable: false, comment: "좋아요"),
Dislikes = table.Column(type: "bigint", nullable: false, comment: "싫어요"),
Blames = table.Column(type: "bigint", nullable: false, comment: "신고 수"),
Replies = table.Column(type: "bigint", nullable: false, comment: "대댓글 수"),
IpAddress = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false, comment: "IP"),
UserAgent = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false, comment: "User-Agent"),
DeletedAt = table.Column(type: "datetime2", nullable: true, comment: "삭제 일시"),
UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시"),
CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "등록 일시")
},
constraints: table =>
{
table.PrimaryKey("PK_Comment", x => x.ID);
table.ForeignKey(
name: "FK_Comment_Board_BoardID",
column: x => x.BoardID,
principalTable: "Board",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Comment_Comment_ParentID",
column: x => x.ParentID,
principalTable: "Comment",
principalColumn: "ID");
table.ForeignKey(
name: "FK_Comment_Member_MemberID",
column: x => x.MemberID,
principalTable: "Member",
principalColumn: "ID");
table.ForeignKey(
name: "FK_Comment_Post_PostID",
column: x => x.PostID,
principalTable: "Post",
principalColumn: "ID");
});
migrationBuilder.CreateIndex(
name: "IX_Board_BoardGroupID",
table: "Board",
column: "BoardGroupID");
migrationBuilder.CreateIndex(
name: "IX_Board_Code",
table: "Board",
column: "Code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Board_Comments",
table: "Board",
column: "Comments");
migrationBuilder.CreateIndex(
name: "IX_Board_IsActive",
table: "Board",
column: "IsActive");
migrationBuilder.CreateIndex(
name: "IX_Board_IsSearch",
table: "Board",
column: "IsSearch");
migrationBuilder.CreateIndex(
name: "IX_Board_Name",
table: "Board",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_Board_Order",
table: "Board",
column: "Order");
migrationBuilder.CreateIndex(
name: "IX_Board_Posts",
table: "Board",
column: "Posts");
migrationBuilder.CreateIndex(
name: "IX_BoardGroup_Boards",
table: "BoardGroup",
column: "Boards");
migrationBuilder.CreateIndex(
name: "IX_BoardGroup_Code",
table: "BoardGroup",
column: "Code");
migrationBuilder.CreateIndex(
name: "IX_BoardGroup_Comments",
table: "BoardGroup",
column: "Comments");
migrationBuilder.CreateIndex(
name: "IX_BoardGroup_Name",
table: "BoardGroup",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_BoardGroup_Order",
table: "BoardGroup",
column: "Order");
migrationBuilder.CreateIndex(
name: "IX_BoardGroup_Posts",
table: "BoardGroup",
column: "Posts");
migrationBuilder.CreateIndex(
name: "IX_BoardMeta_BoardID",
table: "BoardMeta",
column: "BoardID");
migrationBuilder.CreateIndex(
name: "IX_Comment_Blames",
table: "Comment",
column: "Blames");
migrationBuilder.CreateIndex(
name: "IX_Comment_BoardID",
table: "Comment",
column: "BoardID");
migrationBuilder.CreateIndex(
name: "IX_Comment_CreatedAt",
table: "Comment",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_Comment_Dislikes",
table: "Comment",
column: "Dislikes");
migrationBuilder.CreateIndex(
name: "IX_Comment_Email",
table: "Comment",
column: "Email");
migrationBuilder.CreateIndex(
name: "IX_Comment_IsDeleted",
table: "Comment",
column: "IsDeleted");
migrationBuilder.CreateIndex(
name: "IX_Comment_IsSecret",
table: "Comment",
column: "IsSecret");
migrationBuilder.CreateIndex(
name: "IX_Comment_Likes",
table: "Comment",
column: "Likes");
migrationBuilder.CreateIndex(
name: "IX_Comment_MemberID",
table: "Comment",
column: "MemberID");
migrationBuilder.CreateIndex(
name: "IX_Comment_Name",
table: "Comment",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_Comment_ParentID",
table: "Comment",
column: "ParentID");
migrationBuilder.CreateIndex(
name: "IX_Comment_PostID",
table: "Comment",
column: "PostID");
migrationBuilder.CreateIndex(
name: "IX_Comment_Replies",
table: "Comment",
column: "Replies");
migrationBuilder.CreateIndex(
name: "IX_Comment_SID",
table: "Comment",
column: "SID");
migrationBuilder.CreateIndex(
name: "IX_CommentMeta_BoardID",
table: "CommentMeta",
column: "BoardID");
migrationBuilder.CreateIndex(
name: "IX_Post_Blames",
table: "Post",
column: "Blames");
migrationBuilder.CreateIndex(
name: "IX_Post_BoardID",
table: "Post",
column: "BoardID");
migrationBuilder.CreateIndex(
name: "IX_Post_Comments",
table: "Post",
column: "Comments");
migrationBuilder.CreateIndex(
name: "IX_Post_CreatedAt",
table: "Post",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_Post_Dislikes",
table: "Post",
column: "Dislikes");
migrationBuilder.CreateIndex(
name: "IX_Post_Email",
table: "Post",
column: "Email");
migrationBuilder.CreateIndex(
name: "IX_Post_Files",
table: "Post",
column: "Files");
migrationBuilder.CreateIndex(
name: "IX_Post_Images",
table: "Post",
column: "Images");
migrationBuilder.CreateIndex(
name: "IX_Post_IsDeleted",
table: "Post",
column: "IsDeleted");
migrationBuilder.CreateIndex(
name: "IX_Post_IsNotice",
table: "Post",
column: "IsNotice");
migrationBuilder.CreateIndex(
name: "IX_Post_IsReply",
table: "Post",
column: "IsReply");
migrationBuilder.CreateIndex(
name: "IX_Post_IsSecret",
table: "Post",
column: "IsSecret");
migrationBuilder.CreateIndex(
name: "IX_Post_IsSpeaker",
table: "Post",
column: "IsSpeaker");
migrationBuilder.CreateIndex(
name: "IX_Post_LastCommentUpdatedAt",
table: "Post",
column: "LastCommentUpdatedAt");
migrationBuilder.CreateIndex(
name: "IX_Post_LastReplyUpdatedAt",
table: "Post",
column: "LastReplyUpdatedAt");
migrationBuilder.CreateIndex(
name: "IX_Post_Likes",
table: "Post",
column: "Likes");
migrationBuilder.CreateIndex(
name: "IX_Post_MemberID",
table: "Post",
column: "MemberID");
migrationBuilder.CreateIndex(
name: "IX_Post_Name",
table: "Post",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_Post_SID",
table: "Post",
column: "SID");
migrationBuilder.CreateIndex(
name: "IX_Post_Subject",
table: "Post",
column: "Subject");
migrationBuilder.CreateIndex(
name: "IX_Post_Tags",
table: "Post",
column: "Tags");
migrationBuilder.CreateIndex(
name: "IX_Post_Videos",
table: "Post",
column: "Videos");
migrationBuilder.CreateIndex(
name: "IX_Post_Views",
table: "Post",
column: "Views");
migrationBuilder.CreateIndex(
name: "IX_PostMeta_BoardID",
table: "PostMeta",
column: "BoardID");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BoardMeta");
migrationBuilder.DropTable(
name: "Comment");
migrationBuilder.DropTable(
name: "CommentMeta");
migrationBuilder.DropTable(
name: "PostMeta");
migrationBuilder.DropTable(
name: "Post");
migrationBuilder.DropTable(
name: "Board");
migrationBuilder.DropTable(
name: "BoardGroup");
}
}
}