20210921220939_InitialCreate.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Metadata;
  3. using Microsoft.EntityFrameworkCore.Migrations;
  4. namespace GreenTree.Maschinenbestellungen.Domain.Migrations
  5. {
  6. public partial class InitialCreate : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.CreateTable(
  11. name: "Policies",
  12. columns: table => new
  13. {
  14. Name = table.Column<string>(nullable: false)
  15. },
  16. constraints: table =>
  17. {
  18. table.PrimaryKey("PK_Policies", x => x.Name);
  19. });
  20. migrationBuilder.CreateTable(
  21. name: "Users",
  22. columns: table => new
  23. {
  24. Id = table.Column<int>(nullable: false)
  25. .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
  26. Accountname = table.Column<string>(nullable: false),
  27. Forename = table.Column<string>(nullable: false),
  28. Lastname = table.Column<string>(nullable: false),
  29. MailAddress = table.Column<string>(nullable: false),
  30. Password = table.Column<string>(nullable: false),
  31. Birthdate = table.Column<DateTime>(nullable: true),
  32. Activated = table.Column<bool>(nullable: false, defaultValue: true)
  33. },
  34. constraints: table =>
  35. {
  36. table.PrimaryKey("PK_Users", x => x.Id);
  37. });
  38. migrationBuilder.CreateTable(
  39. name: "UserPolicies",
  40. columns: table => new
  41. {
  42. PolicyName = table.Column<string>(nullable: false),
  43. UserId = table.Column<int>(nullable: false)
  44. },
  45. constraints: table =>
  46. {
  47. table.PrimaryKey("PK_UserPolicies", x => new { x.UserId, x.PolicyName });
  48. table.ForeignKey(
  49. name: "FK_UserPolicies_Users_UserId",
  50. column: x => x.UserId,
  51. principalTable: "Users",
  52. principalColumn: "Id",
  53. onDelete: ReferentialAction.Cascade);
  54. });
  55. }
  56. protected override void Down(MigrationBuilder migrationBuilder)
  57. {
  58. migrationBuilder.DropTable(
  59. name: "Policies");
  60. migrationBuilder.DropTable(
  61. name: "UserPolicies");
  62. migrationBuilder.DropTable(
  63. name: "Users");
  64. }
  65. }
  66. }