20250119234313_AddPopupTable.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace bitforum.Migrations.DefaultDb
  5. {
  6. /// <inheritdoc />
  7. public partial class AddPopupTable : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.DropIndex(
  13. name: "IX_Document_IsActive",
  14. table: "Document");
  15. migrationBuilder.CreateTable(
  16. name: "Popup",
  17. columns: table => new
  18. {
  19. ID = table.Column<int>(type: "int", nullable: false)
  20. .Annotation("SqlServer:Identity", "1, 1"),
  21. Subject = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
  22. Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
  23. Link = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
  24. StartAt = table.Column<DateTime>(type: "datetime2", nullable: true),
  25. EndAt = table.Column<DateTime>(type: "datetime2", nullable: true),
  26. Order = table.Column<int>(type: "int", nullable: false),
  27. IsActive = table.Column<bool>(type: "bit", nullable: false),
  28. Views = table.Column<int>(type: "int", nullable: false),
  29. UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
  30. CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
  31. },
  32. constraints: table =>
  33. {
  34. table.PrimaryKey("PK_Popup", x => x.ID);
  35. });
  36. migrationBuilder.CreateIndex(
  37. name: "IX_Document_IsActive",
  38. table: "Document",
  39. column: "IsActive");
  40. migrationBuilder.CreateIndex(
  41. name: "IX_Popup_IsActive",
  42. table: "Popup",
  43. column: "IsActive");
  44. }
  45. /// <inheritdoc />
  46. protected override void Down(MigrationBuilder migrationBuilder)
  47. {
  48. migrationBuilder.DropTable(
  49. name: "Popup");
  50. migrationBuilder.DropIndex(
  51. name: "IX_Document_IsActive",
  52. table: "Document");
  53. migrationBuilder.CreateIndex(
  54. name: "IX_Document_IsActive",
  55. table: "Document",
  56. column: "IsActive",
  57. unique: true);
  58. }
  59. }
  60. }