Добавлена начальная миграция
This commit is contained in:
parent
f6a10e629a
commit
be0a3cd20a
382
VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/20240430193057_InitialCreate.Designer.cs
generated
Normal file
382
VeterinaryClinic/VeterinaryClinicDatabaseImplement/Migrations/20240430193057_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,382 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using VeterinaryClinicDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VeterinaryClinicDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(VeterinaryClinicDatabase))]
|
||||
[Migration("20240430193057_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Age")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Breed")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Animals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.AnimalMedication", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MedicationId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("MedicationId");
|
||||
|
||||
b.ToTable("AnimalMedications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Medication", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Medications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Cost")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MedicationId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicationId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateInjection")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ValidityPeriod")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Vaccinations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.AnimalMedication", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal")
|
||||
.WithMany("Medications")
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Medication", "Medication")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("Medication");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Medication", "Medication")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Medication");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal")
|
||||
.WithMany()
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal")
|
||||
.WithMany()
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Service");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Navigation("Medications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,303 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VeterinaryClinicDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Medications",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Medications", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FullName = table.Column<string>(type: "text", nullable: false),
|
||||
Phone = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
Role = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<int>(type: "integer", nullable: false),
|
||||
MedicationId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Services", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Services_Medications_MedicationId",
|
||||
column: x => x.MedicationId,
|
||||
principalTable: "Medications",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Animals",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Type = table.Column<string>(type: "text", nullable: false),
|
||||
Breed = table.Column<string>(type: "text", nullable: false),
|
||||
Age = table.Column<int>(type: "integer", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Animals", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Animals_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Visits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Date = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Visits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AnimalMedications",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
AnimalId = table.Column<int>(type: "integer", nullable: false),
|
||||
MedicationId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AnimalMedications", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_AnimalMedications_Animals_AnimalId",
|
||||
column: x => x.AnimalId,
|
||||
principalTable: "Animals",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_AnimalMedications_Medications_MedicationId",
|
||||
column: x => x.MedicationId,
|
||||
principalTable: "Medications",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Vaccinations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
DateInjection = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
ValidityPeriod = table.Column<string>(type: "text", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
AnimalId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Vaccinations", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Vaccinations_Animals_AnimalId",
|
||||
column: x => x.AnimalId,
|
||||
principalTable: "Animals",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Vaccinations_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "VisitAnimals",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
VisitId = table.Column<int>(type: "integer", nullable: false),
|
||||
AnimalId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_VisitAnimals", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_VisitAnimals_Animals_AnimalId",
|
||||
column: x => x.AnimalId,
|
||||
principalTable: "Animals",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_VisitAnimals_Visits_VisitId",
|
||||
column: x => x.VisitId,
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "VisitServices",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
VisitId = table.Column<int>(type: "integer", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_VisitServices", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_VisitServices_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_VisitServices_Visits_VisitId",
|
||||
column: x => x.VisitId,
|
||||
principalTable: "Visits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AnimalMedications_AnimalId",
|
||||
table: "AnimalMedications",
|
||||
column: "AnimalId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AnimalMedications_MedicationId",
|
||||
table: "AnimalMedications",
|
||||
column: "MedicationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Animals_UserId",
|
||||
table: "Animals",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Services_MedicationId",
|
||||
table: "Services",
|
||||
column: "MedicationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Vaccinations_AnimalId",
|
||||
table: "Vaccinations",
|
||||
column: "AnimalId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Vaccinations_UserId",
|
||||
table: "Vaccinations",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VisitAnimals_AnimalId",
|
||||
table: "VisitAnimals",
|
||||
column: "AnimalId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VisitAnimals_VisitId",
|
||||
table: "VisitAnimals",
|
||||
column: "VisitId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_UserId",
|
||||
table: "Visits",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VisitServices_ServiceId",
|
||||
table: "VisitServices",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VisitServices_VisitId",
|
||||
table: "VisitServices",
|
||||
column: "VisitId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AnimalMedications");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Vaccinations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "VisitAnimals");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "VisitServices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Animals");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Services");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Visits");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Medications");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,379 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using VeterinaryClinicDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace VeterinaryClinicDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(VeterinaryClinicDatabase))]
|
||||
partial class VeterinaryClinicDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Age")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Breed")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Animals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.AnimalMedication", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MedicationId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("MedicationId");
|
||||
|
||||
b.ToTable("AnimalMedications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Medication", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Medications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Cost")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("MedicationId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicationId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateInjection")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ValidityPeriod")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Vaccinations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AnimalId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AnimalId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitAnimals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("VisitId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.HasIndex("VisitId");
|
||||
|
||||
b.ToTable("VisitServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.AnimalMedication", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal")
|
||||
.WithMany("Medications")
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Medication", "Medication")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("Medication");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Medication", "Medication")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Medication");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Vaccination", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal")
|
||||
.WithMany()
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitAnimal", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Animal", "Animal")
|
||||
.WithMany()
|
||||
.HasForeignKey("AnimalId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Animals")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Animal");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.VisitService", b =>
|
||||
{
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("VeterinaryClinicDatabaseImplement.Models.Visit", "Visit")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("VisitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Service");
|
||||
|
||||
b.Navigation("Visit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Animal", b =>
|
||||
{
|
||||
b.Navigation("Medications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("VeterinaryClinicDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Navigation("Animals");
|
||||
|
||||
b.Navigation("Services");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ namespace VeterinaryClinicDatabaseImplement.Models
|
||||
|
||||
public virtual User User { get; set; } = new();
|
||||
|
||||
[ForeignKey("AnimalId")]
|
||||
[ForeignKey("VisitId")]
|
||||
public virtual List<VisitAnimal> Animals { get; set; } = new();
|
||||
|
||||
private Dictionary<int, IAnimalModel>? _visitAnimals = null;
|
||||
@ -40,7 +40,7 @@ namespace VeterinaryClinicDatabaseImplement.Models
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("ServiceId")]
|
||||
[ForeignKey("VisitId")]
|
||||
public virtual List<VisitService> Services { get; set; } = new();
|
||||
|
||||
private Dictionary<int, IServiceModel>? _visitServices = null;
|
||||
|
@ -6,4 +6,17 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VeterinaryClinicContracts\VeterinaryClinicContracts.csproj" />
|
||||
<ProjectReference Include="..\VeterinaryClinicDatabaseImplement\VeterinaryClinicDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\VeterinaryClinicDataModels\VeterinaryClinicDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user