Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

20230203064003_AddedFileEntity.cs 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Diligent.WebAPI.Data.Migrations
  4. {
  5. public partial class AddedFileEntity : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "Files",
  11. columns: table => new
  12. {
  13. Id = table.Column<int>(type: "int", nullable: false)
  14. .Annotation("SqlServer:Identity", "1, 1"),
  15. Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
  16. Size = table.Column<long>(type: "bigint", nullable: false),
  17. Extension = table.Column<string>(type: "nvarchar(max)", nullable: false)
  18. },
  19. constraints: table =>
  20. {
  21. table.PrimaryKey("PK_Files", x => x.Id);
  22. });
  23. migrationBuilder.CreateTable(
  24. name: "Tags",
  25. columns: table => new
  26. {
  27. Id = table.Column<int>(type: "int", nullable: false)
  28. .Annotation("SqlServer:Identity", "1, 1"),
  29. Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
  30. },
  31. constraints: table =>
  32. {
  33. table.PrimaryKey("PK_Tags", x => x.Id);
  34. });
  35. migrationBuilder.CreateTable(
  36. name: "Categories",
  37. columns: table => new
  38. {
  39. Id = table.Column<int>(type: "int", nullable: false)
  40. .Annotation("SqlServer:Identity", "1, 1"),
  41. Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
  42. FileId = table.Column<int>(type: "int", nullable: false)
  43. },
  44. constraints: table =>
  45. {
  46. table.PrimaryKey("PK_Categories", x => x.Id);
  47. table.ForeignKey(
  48. name: "FK_Categories_Files_FileId",
  49. column: x => x.FileId,
  50. principalTable: "Files",
  51. principalColumn: "Id",
  52. onDelete: ReferentialAction.Cascade);
  53. });
  54. migrationBuilder.CreateTable(
  55. name: "FileEntityTag",
  56. columns: table => new
  57. {
  58. FilesId = table.Column<int>(type: "int", nullable: false),
  59. TagsId = table.Column<int>(type: "int", nullable: false)
  60. },
  61. constraints: table =>
  62. {
  63. table.PrimaryKey("PK_FileEntityTag", x => new { x.FilesId, x.TagsId });
  64. table.ForeignKey(
  65. name: "FK_FileEntityTag_Files_FilesId",
  66. column: x => x.FilesId,
  67. principalTable: "Files",
  68. principalColumn: "Id",
  69. onDelete: ReferentialAction.Cascade);
  70. table.ForeignKey(
  71. name: "FK_FileEntityTag_Tags_TagsId",
  72. column: x => x.TagsId,
  73. principalTable: "Tags",
  74. principalColumn: "Id",
  75. onDelete: ReferentialAction.Cascade);
  76. });
  77. migrationBuilder.CreateIndex(
  78. name: "IX_Categories_FileId",
  79. table: "Categories",
  80. column: "FileId");
  81. migrationBuilder.CreateIndex(
  82. name: "IX_FileEntityTag_TagsId",
  83. table: "FileEntityTag",
  84. column: "TagsId");
  85. }
  86. protected override void Down(MigrationBuilder migrationBuilder)
  87. {
  88. migrationBuilder.DropTable(
  89. name: "Categories");
  90. migrationBuilder.DropTable(
  91. name: "FileEntityTag");
  92. migrationBuilder.DropTable(
  93. name: "Files");
  94. migrationBuilder.DropTable(
  95. name: "Tags");
  96. }
  97. }
  98. }