20240916101932_chatTbls.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace MTWorkHR.Infrastructure.Migrations
  5. {
  6. /// <inheritdoc />
  7. public partial class chatTbls : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.AddColumn<DateTime>(
  13. name: "CreateDate",
  14. table: "AspNetUsers",
  15. type: "datetime2",
  16. nullable: true);
  17. migrationBuilder.AddColumn<DateTime>(
  18. name: "UpdateDate",
  19. table: "AspNetUsers",
  20. type: "datetime2",
  21. nullable: true);
  22. migrationBuilder.CreateTable(
  23. name: "ChatMessages",
  24. columns: table => new
  25. {
  26. Id = table.Column<long>(type: "bigint", nullable: false)
  27. .Annotation("SqlServer:Identity", "1, 1"),
  28. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  29. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  30. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  31. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  32. SenderId = table.Column<string>(type: "nvarchar(max)", nullable: false),
  33. SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
  34. ReceiverId = table.Column<string>(type: "nvarchar(max)", nullable: false),
  35. ReceiverName = table.Column<string>(type: "nvarchar(max)", nullable: false),
  36. Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
  37. IsSeen = table.Column<bool>(type: "bit", nullable: false)
  38. },
  39. constraints: table =>
  40. {
  41. table.PrimaryKey("PK_ChatMessages", x => x.Id);
  42. });
  43. migrationBuilder.CreateTable(
  44. name: "ChatAttachment",
  45. columns: table => new
  46. {
  47. Id = table.Column<long>(type: "bigint", nullable: false)
  48. .Annotation("SqlServer:Identity", "1, 1"),
  49. CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  50. UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
  51. CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  52. UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
  53. ChatMessageId = table.Column<long>(type: "bigint", nullable: false),
  54. FileName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: true),
  55. FilePath = table.Column<string>(type: "nvarchar(max)", nullable: false),
  56. FileType = table.Column<string>(type: "nvarchar(max)", nullable: false),
  57. ContentType = table.Column<string>(type: "nvarchar(max)", nullable: true)
  58. },
  59. constraints: table =>
  60. {
  61. table.PrimaryKey("PK_ChatAttachment", x => x.Id);
  62. table.ForeignKey(
  63. name: "FK_ChatAttachment_ChatMessages_ChatMessageId",
  64. column: x => x.ChatMessageId,
  65. principalTable: "ChatMessages",
  66. principalColumn: "Id",
  67. onDelete: ReferentialAction.Cascade);
  68. });
  69. migrationBuilder.UpdateData(
  70. table: "AspNetUsers",
  71. keyColumn: "Id",
  72. keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
  73. columns: new[] { "CreateDate", "UpdateDate" },
  74. values: new object[] { null, null });
  75. migrationBuilder.UpdateData(
  76. table: "AspNetUsers",
  77. keyColumn: "Id",
  78. keyValue: "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
  79. columns: new[] { "CreateDate", "UpdateDate" },
  80. values: new object[] { null, null });
  81. migrationBuilder.CreateIndex(
  82. name: "IX_ChatAttachment_ChatMessageId",
  83. table: "ChatAttachment",
  84. column: "ChatMessageId");
  85. }
  86. /// <inheritdoc />
  87. protected override void Down(MigrationBuilder migrationBuilder)
  88. {
  89. migrationBuilder.DropTable(
  90. name: "ChatAttachment");
  91. migrationBuilder.DropTable(
  92. name: "ChatMessages");
  93. migrationBuilder.DropColumn(
  94. name: "CreateDate",
  95. table: "AspNetUsers");
  96. migrationBuilder.DropColumn(
  97. name: "UpdateDate",
  98. table: "AspNetUsers");
  99. }
  100. }
  101. }