選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

20220331142133_Initial.cs 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Diligent.WebAPI.Data.Migrations
  5. {
  6. public partial class Initial : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.CreateTable(
  11. name: "InsuranceCompanies",
  12. columns: table => new
  13. {
  14. Id = table.Column<long>(type: "bigint", nullable: false)
  15. .Annotation("SqlServer:Identity", "1, 1"),
  16. Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
  17. PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
  18. Fax = table.Column<string>(type: "nvarchar(max)", nullable: false),
  19. City = table.Column<string>(type: "nvarchar(max)", nullable: false),
  20. Country = table.Column<string>(type: "nvarchar(max)", nullable: false),
  21. PostalCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
  22. LegalAddress = table.Column<string>(type: "nvarchar(max)", nullable: false),
  23. LegalEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
  24. CreatedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: false),
  25. UpdatedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: true),
  26. DeletedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: true)
  27. },
  28. constraints: table =>
  29. {
  30. table.PrimaryKey("PK_InsuranceCompanies", x => x.Id);
  31. });
  32. migrationBuilder.CreateTable(
  33. name: "Insurers",
  34. columns: table => new
  35. {
  36. Id = table.Column<long>(type: "bigint", nullable: false)
  37. .Annotation("SqlServer:Identity", "1, 1"),
  38. FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
  39. LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
  40. DateOfBirth = table.Column<DateTime>(type: "datetime2", nullable: false),
  41. PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
  42. City = table.Column<string>(type: "nvarchar(max)", nullable: false),
  43. Country = table.Column<string>(type: "nvarchar(max)", nullable: false),
  44. PostalCode = table.Column<string>(type: "nvarchar(max)", nullable: false),
  45. Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
  46. Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
  47. InsuranceCompanyId = table.Column<long>(type: "bigint", nullable: false),
  48. CreatedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: false),
  49. UpdatedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: true),
  50. DeletedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: true)
  51. },
  52. constraints: table =>
  53. {
  54. table.PrimaryKey("PK_Insurers", x => x.Id);
  55. table.ForeignKey(
  56. name: "FK_Insurers_InsuranceCompanies_InsuranceCompanyId",
  57. column: x => x.InsuranceCompanyId,
  58. principalTable: "InsuranceCompanies",
  59. principalColumn: "Id",
  60. onDelete: ReferentialAction.Cascade);
  61. });
  62. migrationBuilder.CreateTable(
  63. name: "InsurancePolicies",
  64. columns: table => new
  65. {
  66. Id = table.Column<long>(type: "bigint", nullable: false)
  67. .Annotation("SqlServer:Identity", "1, 1"),
  68. Premium = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
  69. StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  70. EndDate = table.Column<DateTime>(type: "datetime2", nullable: false),
  71. Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
  72. InsurerId = table.Column<long>(type: "bigint", nullable: false),
  73. CreatedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: false),
  74. UpdatedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: true),
  75. DeletedAtUtc = table.Column<DateTime>(type: "datetime2", nullable: true)
  76. },
  77. constraints: table =>
  78. {
  79. table.PrimaryKey("PK_InsurancePolicies", x => x.Id);
  80. table.ForeignKey(
  81. name: "FK_InsurancePolicies_Insurers_InsurerId",
  82. column: x => x.InsurerId,
  83. principalTable: "Insurers",
  84. principalColumn: "Id",
  85. onDelete: ReferentialAction.Cascade);
  86. });
  87. migrationBuilder.CreateIndex(
  88. name: "IX_InsurancePolicies_InsurerId",
  89. table: "InsurancePolicies",
  90. column: "InsurerId");
  91. migrationBuilder.CreateIndex(
  92. name: "IX_Insurers_InsuranceCompanyId",
  93. table: "Insurers",
  94. column: "InsuranceCompanyId");
  95. }
  96. protected override void Down(MigrationBuilder migrationBuilder)
  97. {
  98. migrationBuilder.DropTable(
  99. name: "InsurancePolicies");
  100. migrationBuilder.DropTable(
  101. name: "Insurers");
  102. migrationBuilder.DropTable(
  103. name: "InsuranceCompanies");
  104. }
  105. }
  106. }