This commit is contained in:
Никита Потапов 2024-05-30 03:15:59 +04:00
commit 9ac54dfaec
4 changed files with 44 additions and 10 deletions

View File

@ -12,7 +12,7 @@ using SecuritySystemDatabaseImplement;
namespace PolyclinicDatabaseImplement.Migrations namespace PolyclinicDatabaseImplement.Migrations
{ {
[DbContext(typeof(PolyclinicDatabase))] [DbContext(typeof(PolyclinicDatabase))]
[Migration("20240529230147_For-Medicaments")] [Migration("20240529231348_For-Medicaments")]
partial class ForMedicaments partial class ForMedicaments
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -120,7 +120,6 @@ namespace PolyclinicDatabaseImplement.Migrations
.HasColumnType("int"); .HasColumnType("int");
b.Property<int?>("SymptomId") b.Property<int?>("SymptomId")
.IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -342,9 +341,7 @@ namespace PolyclinicDatabaseImplement.Migrations
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom") b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany() .WithMany()
.HasForeignKey("SymptomId") .HasForeignKey("SymptomId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Procedure"); b.Navigation("Procedure");

View File

@ -14,6 +14,10 @@ namespace PolyclinicDatabaseImplement.Migrations
name: "FK_Medicaments_Procedures_ProcedureId", name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments"); table: "Medicaments");
migrationBuilder.DropForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
table: "Medicaments");
migrationBuilder.AlterColumn<string>( migrationBuilder.AlterColumn<string>(
name: "Comment", name: "Comment",
table: "Symptomes", table: "Symptomes",
@ -38,6 +42,14 @@ namespace PolyclinicDatabaseImplement.Migrations
oldClrType: typeof(string), oldClrType: typeof(string),
oldType: "nvarchar(max)"); oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<int>(
name: "SymptomId",
table: "Medicaments",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<int>( migrationBuilder.AlterColumn<int>(
name: "ProcedureId", name: "ProcedureId",
table: "Medicaments", table: "Medicaments",
@ -76,6 +88,13 @@ namespace PolyclinicDatabaseImplement.Migrations
column: "ProcedureId", column: "ProcedureId",
principalTable: "Procedures", principalTable: "Procedures",
principalColumn: "Id"); principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
table: "Medicaments",
column: "SymptomId",
principalTable: "Symptomes",
principalColumn: "Id");
} }
/// <inheritdoc /> /// <inheritdoc />
@ -85,6 +104,10 @@ namespace PolyclinicDatabaseImplement.Migrations
name: "FK_Medicaments_Procedures_ProcedureId", name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments"); table: "Medicaments");
migrationBuilder.DropForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
table: "Medicaments");
migrationBuilder.AlterColumn<string>( migrationBuilder.AlterColumn<string>(
name: "Comment", name: "Comment",
table: "Symptomes", table: "Symptomes",
@ -115,6 +138,16 @@ namespace PolyclinicDatabaseImplement.Migrations
oldType: "nvarchar(max)", oldType: "nvarchar(max)",
oldNullable: true); oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "SymptomId",
table: "Medicaments",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>( migrationBuilder.AlterColumn<int>(
name: "ProcedureId", name: "ProcedureId",
table: "Medicaments", table: "Medicaments",
@ -162,6 +195,14 @@ namespace PolyclinicDatabaseImplement.Migrations
principalTable: "Procedures", principalTable: "Procedures",
principalColumn: "Id", principalColumn: "Id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Medicaments_Symptomes_SymptomId",
table: "Medicaments",
column: "SymptomId",
principalTable: "Symptomes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
} }
} }
} }

View File

@ -117,7 +117,6 @@ namespace PolyclinicDatabaseImplement.Migrations
.HasColumnType("int"); .HasColumnType("int");
b.Property<int?>("SymptomId") b.Property<int?>("SymptomId")
.IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
@ -339,9 +338,7 @@ namespace PolyclinicDatabaseImplement.Migrations
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom") b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany() .WithMany()
.HasForeignKey("SymptomId") .HasForeignKey("SymptomId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Procedure"); b.Navigation("Procedure");

View File

@ -17,7 +17,6 @@ namespace PolyclinicDatabaseImplement.Models
public int? ProcedureId { get; set; } public int? ProcedureId { get; set; }
[Required]
public int? SymptomId { get; set; } public int? SymptomId { get; set; }
public virtual Symptom? Symptom { get; set; } public virtual Symptom? Symptom { get; set; }