using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations.AppDb;
///
public partial class SeedFeedBoard : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
SET XACT_ABORT ON;
IF NOT EXISTS (SELECT 1 FROM BoardGroup WHERE Code = 'feed')
BEGIN
INSERT INTO BoardGroup (Code, Name, [Order], Boards, Posts, Comments, CreatedAt)
VALUES ('feed', N'피드', 100, 0, 0, 0, SYSUTCDATETIME());
END;
IF NOT EXISTS (SELECT 1 FROM Board WHERE Code = 'feed')
BEGIN
DECLARE @GroupID INT = (SELECT TOP 1 ID FROM BoardGroup WHERE Code = 'feed');
INSERT INTO Board (BoardGroupID, Code, Name, [Order], IsSearch, IsActive, Posts, Comments, CreatedAt)
VALUES (@GroupID, 'feed', N'피드', 0, 0, 1, 0, 0, SYSUTCDATETIME());
DECLARE @BoardID INT = SCOPE_IDENTITY();
INSERT INTO BoardMeta (
BoardID,
List_ShowHeader, List_ShowFooter, List_Layout, List_Sort, List_PerPage,
List_AlwaysShowWriteButton, List_ShowFooterListView, List_IsNewIcon, List_IsHotIcon,
List_ExceptNotice, List_ExceptSpeaker,
View_AllowBookmark, View_AllowLike, View_AllowDislike, View_AllowPrint, View_AllowSnsShare,
View_AllowPrevNextBotton, View_AllowBlame, View_BlameHideCount,
View_AllowContentLinkTargetBlank, View_AllowPostUrlCopy, View_AllowPostUrlQrCode,
View_ShowMemberThumb, View_ShowMemberIcon, View_ShowMemberRegDate, View_ShowMemberSummary,
Write_ShowHeader, Write_ShowFooter, Write_AllowEditor, Write_AllowPrefix, Write_RequiredPrefix,
Write_AllowSecret, Write_AllowTag, Write_TagLimit,
Write_AllowImage, Write_ImageUploadLimit, Write_ImageUploadMaxSize,
Write_AllowMedia, Write_MediaUploadLimit,
Write_AllowFile, Write_FileUploadLimit, Write_FileUploadMaxSize,
Comment_EnableComment, Comment_PerPage, Comment_AllowLike, Comment_AllowDisLike,
Comment_ShowMemberThumb, Comment_ShowMemberIcon, Comment_MinContentLength, Comment_MaxContentLength,
Comment_EnableEditor, Comment_AllowSecret, Comment_BlameHideCount,
Comment_DeleteProtectionDays, Comment_UpdateProtectionDays,
Comment_AllowDeleteProtection, Comment_AllowUpdateProtection, Comment_EnableCommentUpdateLog,
General_DeleteProtectionDays, General_UpdateProtectionDays,
General_AllowDeleteProtection, General_AllowUpdateProtection,
General_EnableFileDownLog, General_EnableLinkClickLog, General_EnablePostUpdateLog,
Permission_BoardAccess, Permission_PostView, Permission_PostWrite,
Permission_CommentView, Permission_CommentWrite, Permission_ReplyWrite,
Permission_FileUpload, Permission_FileDownload,
Exp_EnableExp, Exp_ShowExpGuide,
Exp_PostWriteExp, Exp_CommentWriteExp, Exp_FileUploadExp, Exp_FileDownloadExp,
Exp_OtherPostReadExp, Exp_OtherPostLikeExp, Exp_OtherPostDisLikeExp,
Exp_OtherCommentLikeExp, Exp_OtherCommentDisLikeExp,
Exp_OwnPostReadExp, Exp_OwnPostLikeExp, Exp_OwnPostDisLikeExp,
Exp_OwnCommentLikeExp, Exp_OwnCommentDisLikeExp,
Exp_PostWriteUndoExp, Exp_CommentWriteUndoExp, Exp_FileUploadUndoExp,
Exp_OtherPostReadUndoExp, Exp_OtherPostLikeUndoExp, Exp_OtherPostDisLikeUndoExp,
Exp_OtherCommentLikeUndoExp, Exp_OtherCommentDisLikeUndoExp,
Exp_OwnPostReadUndoExp, Exp_OwnPostLikeUndoExp, Exp_OwnPostDisLikeUndoExp,
Exp_OwnCommentLikeUndoExp, Exp_OwnCommentDisLikeUndoExp,
Exp_PostWriteExpWithinDays, Exp_CommentWriteExpWithinDays, Exp_FileUploadExpWithinDays,
Exp_OtherPostReadExpWithinDays, Exp_OtherPostLikeExpWithinDays, Exp_OtherPostDisLikeExpWithinDays,
Exp_OtherCommentLikeExpWithinDays, Exp_OtherCommentDisLikeExpWithinDays,
Exp_OwnPostReadExpWithinDays, Exp_OwnPostLikeExpWithinDays, Exp_OwnPostDisLikeExpWithinDays,
Exp_OwnCommentLikeExpWithinDays, Exp_OwnCommentDisLikeExpWithinDays
)
VALUES (
@BoardID,
0, 0, 3 /* Feed layout */, NULL, 20,
0, 0, 1, 1,
1 /* ExceptNotice */, 1 /* ExceptSpeaker */,
1, 1, 0, 0, 1,
0, 1, 5,
1, 1, 0,
1, 0, 0, 1,
0, 0, 0, 0, 0,
0, 1, 5,
1, 8, 5242880,
1, 3,
0, 0, 0,
1, 20, 1, 0,
1, 0, 0, 1000,
0, 0, 5,
0, 0,
0, 0, 0,
0, 0,
0, 0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0,
0, 0, 0, 0,
0, 0, 0,
0, 0,
0, 0, 0,
0, 0,
0, 0, 0,
0, 0, 0,
0, 0,
0, 0, 0,
0, 0,
0, 0, 0,
0, 0, 0,
0, 0,
0, 0, 0,
0, 0
);
UPDATE BoardGroup SET Boards = Boards + 1 WHERE ID = @GroupID;
END;
");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"
DELETE FROM BoardMeta WHERE BoardID IN (SELECT ID FROM Board WHERE Code = 'feed');
DELETE FROM Board WHERE Code = 'feed';
DELETE FROM BoardGroup WHERE Code = 'feed';
");
}
}