Keine Beschreibung

20211217155911_20211217_1659.cs 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace Backend.Data.Migrations
  4. {
  5. public partial class _20211217_1659 : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "Commandes",
  11. columns: table => new
  12. {
  13. Id = table.Column<Guid>(type: "char(36)", nullable: false),
  14. NumeroCommande = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: false),
  15. Reference = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: false),
  16. DateEnregistrement = table.Column<DateTime>(type: "datetime(6)", nullable: false)
  17. },
  18. constraints: table =>
  19. {
  20. table.PrimaryKey("PK_Commandes", x => x.Id);
  21. });
  22. migrationBuilder.CreateTable(
  23. name: "Produits",
  24. columns: table => new
  25. {
  26. Id = table.Column<Guid>(type: "char(36)", nullable: false),
  27. Libelle = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: true),
  28. Reference = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: true),
  29. DateEnregistrement = table.Column<DateTime>(type: "datetime(6)", nullable: false)
  30. },
  31. constraints: table =>
  32. {
  33. table.PrimaryKey("PK_Produits", x => x.Id);
  34. });
  35. migrationBuilder.CreateTable(
  36. name: "TypeProprietes",
  37. columns: table => new
  38. {
  39. Id = table.Column<Guid>(type: "char(36)", nullable: false),
  40. Libelle = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: false),
  41. EstArchive = table.Column<bool>(type: "tinyint(1)", nullable: false)
  42. },
  43. constraints: table =>
  44. {
  45. table.PrimaryKey("PK_TypeProprietes", x => x.Id);
  46. });
  47. migrationBuilder.CreateTable(
  48. name: "LigneCommandes",
  49. columns: table => new
  50. {
  51. Id = table.Column<Guid>(type: "char(36)", nullable: false),
  52. ProduitId = table.Column<Guid>(type: "char(36)", nullable: false),
  53. CommandeId = table.Column<Guid>(type: "char(36)", nullable: false),
  54. Quantite = table.Column<int>(type: "int", nullable: false),
  55. Prix = table.Column<decimal>(type: "decimal(65,30)", nullable: false)
  56. },
  57. constraints: table =>
  58. {
  59. table.PrimaryKey("PK_LigneCommandes", x => x.Id);
  60. table.ForeignKey(
  61. name: "FK_LigneCommandes_Commandes_CommandeId",
  62. column: x => x.CommandeId,
  63. principalTable: "Commandes",
  64. principalColumn: "Id",
  65. onDelete: ReferentialAction.Cascade);
  66. table.ForeignKey(
  67. name: "FK_LigneCommandes_Produits_ProduitId",
  68. column: x => x.ProduitId,
  69. principalTable: "Produits",
  70. principalColumn: "Id",
  71. onDelete: ReferentialAction.Cascade);
  72. });
  73. migrationBuilder.CreateTable(
  74. name: "Proprietes",
  75. columns: table => new
  76. {
  77. Id = table.Column<Guid>(type: "char(36)", nullable: false),
  78. ProduitId = table.Column<Guid>(type: "char(36)", nullable: false),
  79. TypeProprieteId = table.Column<Guid>(type: "char(36)", nullable: false),
  80. Valeur = table.Column<string>(type: "longtext CHARACTER SET utf8mb4", nullable: false)
  81. },
  82. constraints: table =>
  83. {
  84. table.PrimaryKey("PK_Proprietes", x => x.Id);
  85. table.ForeignKey(
  86. name: "FK_Proprietes_Produits_ProduitId",
  87. column: x => x.ProduitId,
  88. principalTable: "Produits",
  89. principalColumn: "Id",
  90. onDelete: ReferentialAction.Cascade);
  91. table.ForeignKey(
  92. name: "FK_Proprietes_TypeProprietes_TypeProprieteId",
  93. column: x => x.TypeProprieteId,
  94. principalTable: "TypeProprietes",
  95. principalColumn: "Id",
  96. onDelete: ReferentialAction.Cascade);
  97. });
  98. migrationBuilder.CreateIndex(
  99. name: "IX_LigneCommandes_CommandeId",
  100. table: "LigneCommandes",
  101. column: "CommandeId");
  102. migrationBuilder.CreateIndex(
  103. name: "IX_LigneCommandes_ProduitId",
  104. table: "LigneCommandes",
  105. column: "ProduitId");
  106. migrationBuilder.CreateIndex(
  107. name: "IX_Proprietes_ProduitId",
  108. table: "Proprietes",
  109. column: "ProduitId");
  110. migrationBuilder.CreateIndex(
  111. name: "IX_Proprietes_TypeProprieteId",
  112. table: "Proprietes",
  113. column: "TypeProprieteId");
  114. }
  115. protected override void Down(MigrationBuilder migrationBuilder)
  116. {
  117. migrationBuilder.DropTable(
  118. name: "LigneCommandes");
  119. migrationBuilder.DropTable(
  120. name: "Proprietes");
  121. migrationBuilder.DropTable(
  122. name: "Commandes");
  123. migrationBuilder.DropTable(
  124. name: "Produits");
  125. migrationBuilder.DropTable(
  126. name: "TypeProprietes");
  127. }
  128. }
  129. }

Powered by TurnKey Linux.