20200614195418_InitialCreate.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Metadata;
  3. using Microsoft.EntityFrameworkCore.Migrations;
  4. namespace GreenTree.Strohrmann.ERP.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. Birthdate = table.Column<DateTime>(nullable: true)
  30. },
  31. constraints: table =>
  32. {
  33. table.PrimaryKey("PK_Users", x => x.Id);
  34. });
  35. migrationBuilder.CreateTable(
  36. name: "UserPolicies",
  37. columns: table => new
  38. {
  39. PolicyName = table.Column<string>(nullable: false),
  40. UserId = table.Column<int>(nullable: false)
  41. },
  42. constraints: table =>
  43. {
  44. table.PrimaryKey("PK_UserPolicies", x => new { x.UserId, x.PolicyName });
  45. table.ForeignKey(
  46. name: "FK_UserPolicies_Users_UserId",
  47. column: x => x.UserId,
  48. principalTable: "Users",
  49. principalColumn: "Id",
  50. onDelete: ReferentialAction.Cascade);
  51. });
  52. }
  53. protected override void Down(MigrationBuilder migrationBuilder)
  54. {
  55. migrationBuilder.DropTable(
  56. name: "Policies");
  57. migrationBuilder.DropTable(
  58. name: "UserPolicies");
  59. migrationBuilder.DropTable(
  60. name: "Users");
  61. }
  62. }
  63. }