20260417030046_SeedFeedBoard.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Infrastructure.Migrations.AppDb;
  4. /// <inheritdoc />
  5. public partial class SeedFeedBoard : Migration
  6. {
  7. /// <inheritdoc />
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.Sql(@"
  11. SET XACT_ABORT ON;
  12. IF NOT EXISTS (SELECT 1 FROM BoardGroup WHERE Code = 'feed')
  13. BEGIN
  14. INSERT INTO BoardGroup (Code, Name, [Order], Boards, Posts, Comments, CreatedAt)
  15. VALUES ('feed', N'피드', 100, 0, 0, 0, SYSUTCDATETIME());
  16. END;
  17. IF NOT EXISTS (SELECT 1 FROM Board WHERE Code = 'feed')
  18. BEGIN
  19. DECLARE @GroupID INT = (SELECT TOP 1 ID FROM BoardGroup WHERE Code = 'feed');
  20. INSERT INTO Board (BoardGroupID, Code, Name, [Order], IsSearch, IsActive, Posts, Comments, CreatedAt)
  21. VALUES (@GroupID, 'feed', N'피드', 0, 0, 1, 0, 0, SYSUTCDATETIME());
  22. DECLARE @BoardID INT = SCOPE_IDENTITY();
  23. INSERT INTO BoardMeta (
  24. BoardID,
  25. List_ShowHeader, List_ShowFooter, List_Layout, List_Sort, List_PerPage,
  26. List_AlwaysShowWriteButton, List_ShowFooterListView, List_IsNewIcon, List_IsHotIcon,
  27. List_ExceptNotice, List_ExceptSpeaker,
  28. View_AllowBookmark, View_AllowLike, View_AllowDislike, View_AllowPrint, View_AllowSnsShare,
  29. View_AllowPrevNextBotton, View_AllowBlame, View_BlameHideCount,
  30. View_AllowContentLinkTargetBlank, View_AllowPostUrlCopy, View_AllowPostUrlQrCode,
  31. View_ShowMemberThumb, View_ShowMemberIcon, View_ShowMemberRegDate, View_ShowMemberSummary,
  32. Write_ShowHeader, Write_ShowFooter, Write_AllowEditor, Write_AllowPrefix, Write_RequiredPrefix,
  33. Write_AllowSecret, Write_AllowTag, Write_TagLimit,
  34. Write_AllowImage, Write_ImageUploadLimit, Write_ImageUploadMaxSize,
  35. Write_AllowMedia, Write_MediaUploadLimit,
  36. Write_AllowFile, Write_FileUploadLimit, Write_FileUploadMaxSize,
  37. Comment_EnableComment, Comment_PerPage, Comment_AllowLike, Comment_AllowDisLike,
  38. Comment_ShowMemberThumb, Comment_ShowMemberIcon, Comment_MinContentLength, Comment_MaxContentLength,
  39. Comment_EnableEditor, Comment_AllowSecret, Comment_BlameHideCount,
  40. Comment_DeleteProtectionDays, Comment_UpdateProtectionDays,
  41. Comment_AllowDeleteProtection, Comment_AllowUpdateProtection, Comment_EnableCommentUpdateLog,
  42. General_DeleteProtectionDays, General_UpdateProtectionDays,
  43. General_AllowDeleteProtection, General_AllowUpdateProtection,
  44. General_EnableFileDownLog, General_EnableLinkClickLog, General_EnablePostUpdateLog,
  45. Permission_BoardAccess, Permission_PostView, Permission_PostWrite,
  46. Permission_CommentView, Permission_CommentWrite, Permission_ReplyWrite,
  47. Permission_FileUpload, Permission_FileDownload,
  48. Exp_EnableExp, Exp_ShowExpGuide,
  49. Exp_PostWriteExp, Exp_CommentWriteExp, Exp_FileUploadExp, Exp_FileDownloadExp,
  50. Exp_OtherPostReadExp, Exp_OtherPostLikeExp, Exp_OtherPostDisLikeExp,
  51. Exp_OtherCommentLikeExp, Exp_OtherCommentDisLikeExp,
  52. Exp_OwnPostReadExp, Exp_OwnPostLikeExp, Exp_OwnPostDisLikeExp,
  53. Exp_OwnCommentLikeExp, Exp_OwnCommentDisLikeExp,
  54. Exp_PostWriteUndoExp, Exp_CommentWriteUndoExp, Exp_FileUploadUndoExp,
  55. Exp_OtherPostReadUndoExp, Exp_OtherPostLikeUndoExp, Exp_OtherPostDisLikeUndoExp,
  56. Exp_OtherCommentLikeUndoExp, Exp_OtherCommentDisLikeUndoExp,
  57. Exp_OwnPostReadUndoExp, Exp_OwnPostLikeUndoExp, Exp_OwnPostDisLikeUndoExp,
  58. Exp_OwnCommentLikeUndoExp, Exp_OwnCommentDisLikeUndoExp,
  59. Exp_PostWriteExpWithinDays, Exp_CommentWriteExpWithinDays, Exp_FileUploadExpWithinDays,
  60. Exp_OtherPostReadExpWithinDays, Exp_OtherPostLikeExpWithinDays, Exp_OtherPostDisLikeExpWithinDays,
  61. Exp_OtherCommentLikeExpWithinDays, Exp_OtherCommentDisLikeExpWithinDays,
  62. Exp_OwnPostReadExpWithinDays, Exp_OwnPostLikeExpWithinDays, Exp_OwnPostDisLikeExpWithinDays,
  63. Exp_OwnCommentLikeExpWithinDays, Exp_OwnCommentDisLikeExpWithinDays
  64. )
  65. VALUES (
  66. @BoardID,
  67. 0, 0, 3 /* Feed layout */, NULL, 20,
  68. 0, 0, 1, 1,
  69. 1 /* ExceptNotice */, 1 /* ExceptSpeaker */,
  70. 1, 1, 0, 0, 1,
  71. 0, 1, 5,
  72. 1, 1, 0,
  73. 1, 0, 0, 1,
  74. 0, 0, 0, 0, 0,
  75. 0, 1, 5,
  76. 1, 8, 5242880,
  77. 1, 3,
  78. 0, 0, 0,
  79. 1, 20, 1, 0,
  80. 1, 0, 0, 1000,
  81. 0, 0, 5,
  82. 0, 0,
  83. 0, 0, 0,
  84. 0, 0,
  85. 0, 0, 0, 0,
  86. 0, 0, 0,
  87. 0, 0, 0,
  88. 0, 0, 0,
  89. 0, 0,
  90. 0, 0, 0, 0,
  91. 0, 0, 0,
  92. 0, 0,
  93. 0, 0, 0,
  94. 0, 0,
  95. 0, 0, 0,
  96. 0, 0, 0,
  97. 0, 0,
  98. 0, 0, 0,
  99. 0, 0,
  100. 0, 0, 0,
  101. 0, 0, 0,
  102. 0, 0,
  103. 0, 0, 0,
  104. 0, 0
  105. );
  106. UPDATE BoardGroup SET Boards = Boards + 1 WHERE ID = @GroupID;
  107. END;
  108. ");
  109. }
  110. /// <inheritdoc />
  111. protected override void Down(MigrationBuilder migrationBuilder)
  112. {
  113. migrationBuilder.Sql(@"
  114. DELETE FROM BoardMeta WHERE BoardID IN (SELECT ID FROM Board WHERE Code = 'feed');
  115. DELETE FROM Board WHERE Code = 'feed';
  116. DELETE FROM BoardGroup WHERE Code = 'feed';
  117. ");
  118. }
  119. }