Самая адекватная бд
This commit is contained in:
parent
077bc77908
commit
c08e53d41a
@ -19,16 +19,31 @@ namespace DeviceDatabaseImplement.Migrations
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Room = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Building = table.Column<int>(type: "int", nullable: false),
|
||||
CabinetId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cabinets", x => x.Id);
|
||||
table.PrimaryKey("Cabinets_PKey", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Kits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cabinet_Id = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("Kits_PKey", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cabinets_Cabinets_CabinetId",
|
||||
column: x => x.CabinetId,
|
||||
name: "Kits_Cabinet_Id_FKey",
|
||||
column: x => x.Cabinet_Id,
|
||||
principalTable: "Cabinets",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull,
|
||||
onUpdate: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -42,65 +57,7 @@ namespace DeviceDatabaseImplement.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Kinds", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
StartDate = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
EndDate = table.Column<DateOnly>(type: "date", nullable: true),
|
||||
DeviceId = table.Column<int>(type: "int", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Services", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Services_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Staff",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FullName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Department = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
AccessLevel = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Staff", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Kits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CabinetId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Kits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Kits_Cabinets_CabinetId",
|
||||
column: x => x.CabinetId,
|
||||
principalTable: "Cabinets",
|
||||
principalColumn: "Id");
|
||||
table.PrimaryKey("Kinds_PKey", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -110,82 +67,127 @@ namespace DeviceDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Model = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
SerialNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
ProductionDate = table.Column<DateOnly>(type: "date", nullable: true),
|
||||
WarrantyPeriod = table.Column<int>(type: "int", nullable: true),
|
||||
Serial_Number = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Production_Date = table.Column<DateOnly>(type: "date", nullable: true),
|
||||
Warranty_Period = table.Column<int>(type: "int", nullable: true),
|
||||
Condition = table.Column<bool>(type: "bit", nullable: false),
|
||||
KindId = table.Column<int>(type: "int", nullable: false),
|
||||
KitId = table.Column<int>(type: "int", nullable: true)
|
||||
Kind_Id = table.Column<int>(type: "int", nullable: false),
|
||||
Kit_Id = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Devices", x => x.Id);
|
||||
table.PrimaryKey("Devices_Pkey", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Devices_Kinds_KindId",
|
||||
column: x => x.KindId,
|
||||
name: "Devices_Kind_Id_FKey",
|
||||
column: x => x.Kind_Id,
|
||||
principalTable: "Kinds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
onDelete: ReferentialAction.Restrict,
|
||||
onUpdate: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Devices_Kits_KitId",
|
||||
column: x => x.KitId,
|
||||
name: "Devices_Kit_Id_FKey",
|
||||
column: x => x.Kit_Id,
|
||||
principalTable: "Kits",
|
||||
principalColumn: "Id");
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull,
|
||||
onUpdate: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Start_Date = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
End_Date = table.Column<DateOnly>(type: "date", nullable: true),
|
||||
Device_Id = table.Column<int>(type: "int", nullable: false),
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("Services_PKey", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "Services_Device_Id_FKey",
|
||||
column: x => x.Device_Id,
|
||||
principalTable: "Devices",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade,
|
||||
onUpdate: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Staff",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Full_Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Department = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Access_Level = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("Staff_PKey", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Ownership",
|
||||
columns: table => new
|
||||
{
|
||||
KitId = table.Column<int>(type: "int", nullable: false),
|
||||
StaffId = table.Column<int>(type: "int", nullable: false)
|
||||
Kit_Id = table.Column<int>(type: "int", nullable: false),
|
||||
Staff_Id = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Ownership", x => new { x.StaffId, x.KitId });
|
||||
table.PrimaryKey("PK_Ownership", x => new { x.Staff_Id, x.Kit_Id });
|
||||
table.ForeignKey(
|
||||
name: "FK_Ownership_Kits_KitId",
|
||||
column: x => x.KitId,
|
||||
name: "Ownership_Kit_Id_FKey",
|
||||
column: x => x.Kit_Id,
|
||||
principalTable: "Kits",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
onDelete: ReferentialAction.Cascade,
|
||||
onUpdate: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Ownership_Staff_StaffId",
|
||||
column: x => x.StaffId,
|
||||
name: "Ownership_Staff_Id_FKey",
|
||||
column: x => x.Staff_Id,
|
||||
principalTable: "Staff",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
onDelete: ReferentialAction.Cascade,
|
||||
onUpdate: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cabinets_CabinetId",
|
||||
table: "Cabinets",
|
||||
column: "CabinetId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Devices_KindId",
|
||||
name: "IX_Devices_Kind_Id",
|
||||
table: "Devices",
|
||||
column: "KindId");
|
||||
column: "Kind_Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Devices_KitId",
|
||||
name: "IX_Devices_Kit_Id",
|
||||
table: "Devices",
|
||||
column: "KitId");
|
||||
column: "Kit_Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Kits_CabinetId",
|
||||
name: "IX_Kits_Cabinet_Id",
|
||||
table: "Kits",
|
||||
column: "CabinetId");
|
||||
column: "Cabinet_Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Ownership_KitId",
|
||||
name: "IX_Ownership_Kit_Id",
|
||||
table: "Ownership",
|
||||
column: "KitId");
|
||||
column: "Kit_Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Services_ServiceId",
|
||||
name: "IX_Ownership_Staff_Id",
|
||||
table: "Ownership",
|
||||
column: "Staff_Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Services_Device_Id",
|
||||
table: "Services",
|
||||
column: "ServiceId");
|
||||
column: "Device_Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
@ -1,297 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DeviceDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DeviceDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(DeviceDatabase))]
|
||||
partial class DeviceDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Cabinet", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Building")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("CabinetId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Room")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CabinetId");
|
||||
|
||||
b.ToTable("Cabinets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Device", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<bool>("Condition")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<int>("KindId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("KitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Model")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateOnly?>("ProductionDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("SerialNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("WarrantyPeriod")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("KindId");
|
||||
|
||||
b.HasIndex("KitId");
|
||||
|
||||
b.ToTable("Devices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Kind", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Frequency")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Kinds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Kit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("CabinetId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CabinetId");
|
||||
|
||||
b.ToTable("Kits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Ownership", b =>
|
||||
{
|
||||
b.Property<int>("StaffId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("KitId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("StaffId", "KitId");
|
||||
|
||||
b.HasIndex("KitId");
|
||||
|
||||
b.ToTable("Ownership");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("DeviceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateOnly?>("EndDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<int?>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateOnly>("StartDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Staff", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AccessLevel")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Department")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Staff");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Cabinet", b =>
|
||||
{
|
||||
b.HasOne("DeviceDatabaseImplement.Models.Cabinet", null)
|
||||
.WithMany("Cabinets")
|
||||
.HasForeignKey("CabinetId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Device", b =>
|
||||
{
|
||||
b.HasOne("DeviceDatabaseImplement.Models.Kind", "Kind")
|
||||
.WithMany("Devices")
|
||||
.HasForeignKey("KindId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DeviceDatabaseImplement.Models.Kit", "Kit")
|
||||
.WithMany("Devices")
|
||||
.HasForeignKey("KitId");
|
||||
|
||||
b.Navigation("Kind");
|
||||
|
||||
b.Navigation("Kit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Kit", b =>
|
||||
{
|
||||
b.HasOne("DeviceDatabaseImplement.Models.Cabinet", "Cabinet")
|
||||
.WithMany()
|
||||
.HasForeignKey("CabinetId");
|
||||
|
||||
b.Navigation("Cabinet");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Ownership", b =>
|
||||
{
|
||||
b.HasOne("DeviceDatabaseImplement.Models.Kit", "Kits")
|
||||
.WithMany("Ownership")
|
||||
.HasForeignKey("KitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DeviceDatabaseImplement.Models.Staff", "Staff")
|
||||
.WithMany("Ownership")
|
||||
.HasForeignKey("StaffId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Kits");
|
||||
|
||||
b.Navigation("Staff");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.HasOne("DeviceDatabaseImplement.Models.Service", null)
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("ServiceId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Cabinet", b =>
|
||||
{
|
||||
b.Navigation("Cabinets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Kind", b =>
|
||||
{
|
||||
b.Navigation("Devices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Kit", b =>
|
||||
{
|
||||
b.Navigation("Devices");
|
||||
|
||||
b.Navigation("Ownership");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DeviceDatabaseImplement.Models.Staff", b =>
|
||||
{
|
||||
b.Navigation("Ownership");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user