Обновление базы данных

This commit is contained in:
GokaPek 2024-04-22 14:08:12 +04:00
parent 917c17228f
commit 12a5667646
3 changed files with 165 additions and 45 deletions

View File

@ -9,21 +9,46 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AbstractLawFirmDatabaseImplement.Migrations
namespace AbstractLawFirmDataBaseImplement.Migrations
{
[DbContext(typeof(AbstractLawFirmDatabase))]
[Migration("20240325152423_InitialCreate")]
[Migration("20240422100607_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("DocumentVersion", "6.0.28")
.HasAnnotation("ProductVersion", "6.0.28")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
@ -44,7 +69,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.ToTable("Components");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Document", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.Document", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -64,7 +89,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.ToTable("Documents");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.DocumentComponent", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.DocumentComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -90,7 +115,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.ToTable("DocumentComponents");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Order", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -98,6 +123,9 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
@ -118,12 +146,14 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("DocumentId");
b.ToTable("Orders");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.DocumentComponent", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.DocumentComponent", b =>
{
b.HasOne("AbstractLawFirmDataBaseImplement.Models.Component", "Component")
.WithMany("DocumentComponents")
@ -131,7 +161,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AbstractLawFirmDataBaseImplement.Models.Document", "Document")
b.HasOne("AbstractLawFirmDatabaseImplement.Models.Document", "Document")
.WithMany("Components")
.HasForeignKey("DocumentId")
.OnDelete(DeleteBehavior.Cascade)
@ -142,13 +172,28 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.Navigation("Document");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Order", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.Order", b =>
{
b.HasOne("AbstractLawFirmDataBaseImplement.Models.Document", null)
b.HasOne("AbstractLawFirmDataBaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AbstractLawFirmDatabaseImplement.Models.Document", "Document")
.WithMany("Orders")
.HasForeignKey("DocumentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Document");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Component", b =>
@ -156,7 +201,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.Navigation("DocumentComponents");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Document", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.Document", b =>
{
b.Navigation("Components");

View File

@ -3,12 +3,27 @@ using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AbstractLawFirmDatabaseImplement.Migrations
namespace AbstractLawFirmDataBaseImplement.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = 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)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Components",
columns: table => new
@ -71,6 +86,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DocumentId = table.Column<int>(type: "int", nullable: false),
ClientId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
@ -80,6 +96,12 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Documents_DocumentId",
column: x => x.DocumentId,
@ -98,6 +120,11 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
table: "DocumentComponents",
column: "DocumentId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_DocumentId",
table: "Orders",
@ -115,6 +142,9 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
migrationBuilder.DropTable(
name: "Components");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "Documents");
}

View File

@ -8,20 +8,45 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AbstractLawFirmDatabaseImplement.Migrations
namespace AbstractLawFirmDataBaseImplement.Migrations
{
[DbContext(typeof(AbstractLawFirmDatabase))]
partial class AbstractLawFirmDataBaseModelSnapshot : ModelSnapshot
partial class AbstractLawFirmDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("DocumentVersion", "6.0.28")
.HasAnnotation("ProductVersion", "6.0.28")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
@ -42,7 +67,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.ToTable("Components");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Document", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.Document", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -62,7 +87,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.ToTable("Documents");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.DocumentComponent", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.DocumentComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -88,7 +113,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.ToTable("DocumentComponents");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Order", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -96,6 +121,9 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
@ -116,12 +144,14 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("DocumentId");
b.ToTable("Orders");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.DocumentComponent", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.DocumentComponent", b =>
{
b.HasOne("AbstractLawFirmDataBaseImplement.Models.Component", "Component")
.WithMany("DocumentComponents")
@ -129,7 +159,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AbstractLawFirmDataBaseImplement.Models.Document", "Document")
b.HasOne("AbstractLawFirmDatabaseImplement.Models.Document", "Document")
.WithMany("Components")
.HasForeignKey("DocumentId")
.OnDelete(DeleteBehavior.Cascade)
@ -140,13 +170,28 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.Navigation("Document");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Order", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.Order", b =>
{
b.HasOne("AbstractLawFirmDataBaseImplement.Models.Document", null)
b.HasOne("AbstractLawFirmDataBaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AbstractLawFirmDatabaseImplement.Models.Document", "Document")
.WithMany("Orders")
.HasForeignKey("DocumentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Document");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Component", b =>
@ -154,7 +199,7 @@ namespace AbstractLawFirmDatabaseImplement.Migrations
b.Navigation("DocumentComponents");
});
modelBuilder.Entity("AbstractLawFirmDataBaseImplement.Models.Document", b =>
modelBuilder.Entity("AbstractLawFirmDatabaseImplement.Models.Document", b =>
{
b.Navigation("Components");