This commit is contained in:
kagbie3nn@mail.ru 2024-05-30 21:18:32 +04:00
parent 391cf3746d
commit 33fb7a2e01
3 changed files with 590 additions and 0 deletions

@ -0,0 +1,219 @@
// <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 ZooDataBaseImplement;
#nullable disable
namespace ZooDataBaseImplement.Migrations
{
[DbContext(typeof(ZooDatabase))]
[Migration("20240530171709_Initialcreate")]
partial class Initialcreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.18")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ZooDataBaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EMail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("EmployeeFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Employees");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Preserve", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("EmployeeId")
.HasColumnType("integer");
b.Property<string>("PreserveName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("PreservePrice")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("EmployeeId");
b.ToTable("Preserves");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Route", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime>("DateFinish")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateStart")
.HasColumnType("timestamp with time zone");
b.Property<string>("RouteName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RoutePrice")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Routes");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.RoutePreserve", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("PreserveID")
.HasColumnType("integer");
b.Property<int>("RouteID")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PreserveID");
b.HasIndex("RouteID");
b.ToTable("RoutePreserves");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Preserve", b =>
{
b.HasOne("ZooDataBaseImplement.Models.Employee", null)
.WithMany("Preserves")
.HasForeignKey("EmployeeId");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Route", b =>
{
b.HasOne("ZooDataBaseImplement.Models.Client", "Client")
.WithMany("Routes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.RoutePreserve", b =>
{
b.HasOne("ZooDataBaseImplement.Models.Preserve", "Preserve")
.WithMany("RoutePreserves")
.HasForeignKey("PreserveID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ZooDataBaseImplement.Models.Route", "Route")
.WithMany("Preserves")
.HasForeignKey("RouteID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Preserve");
b.Navigation("Route");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Client", b =>
{
b.Navigation("Routes");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Employee", b =>
{
b.Navigation("Preserves");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Preserve", b =>
{
b.Navigation("RoutePreserves");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Route", b =>
{
b.Navigation("Preserves");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,155 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ZooDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class Initialcreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientFIO = table.Column<string>(type: "text", nullable: false),
EMail = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
EmployeeFIO = table.Column<string>(type: "text", nullable: false),
Login = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Routes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
RouteName = table.Column<string>(type: "text", nullable: false),
RoutePrice = table.Column<double>(type: "double precision", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false),
DateStart = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DateFinish = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Routes", x => x.Id);
table.ForeignKey(
name: "FK_Routes_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Preserves",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PreserveName = table.Column<string>(type: "text", nullable: false),
PreservePrice = table.Column<double>(type: "double precision", nullable: false),
EmployeeId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Preserves", x => x.Id);
table.ForeignKey(
name: "FK_Preserves_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "RoutePreserves",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RouteID = table.Column<int>(type: "integer", nullable: false),
PreserveID = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RoutePreserves", x => x.Id);
table.ForeignKey(
name: "FK_RoutePreserves_Preserves_PreserveID",
column: x => x.PreserveID,
principalTable: "Preserves",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RoutePreserves_Routes_RouteID",
column: x => x.RouteID,
principalTable: "Routes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Preserves_EmployeeId",
table: "Preserves",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_RoutePreserves_PreserveID",
table: "RoutePreserves",
column: "PreserveID");
migrationBuilder.CreateIndex(
name: "IX_RoutePreserves_RouteID",
table: "RoutePreserves",
column: "RouteID");
migrationBuilder.CreateIndex(
name: "IX_Routes_ClientId",
table: "Routes",
column: "ClientId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RoutePreserves");
migrationBuilder.DropTable(
name: "Preserves");
migrationBuilder.DropTable(
name: "Routes");
migrationBuilder.DropTable(
name: "Employees");
migrationBuilder.DropTable(
name: "Clients");
}
}
}

@ -0,0 +1,216 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using ZooDataBaseImplement;
#nullable disable
namespace ZooDataBaseImplement.Migrations
{
[DbContext(typeof(ZooDatabase))]
partial class ZooDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.18")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ZooDataBaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EMail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("EmployeeFIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Employees");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Preserve", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("EmployeeId")
.HasColumnType("integer");
b.Property<string>("PreserveName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("PreservePrice")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("EmployeeId");
b.ToTable("Preserves");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Route", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<DateTime>("DateFinish")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateStart")
.HasColumnType("timestamp with time zone");
b.Property<string>("RouteName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("RoutePrice")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Routes");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.RoutePreserve", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("PreserveID")
.HasColumnType("integer");
b.Property<int>("RouteID")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("PreserveID");
b.HasIndex("RouteID");
b.ToTable("RoutePreserves");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Preserve", b =>
{
b.HasOne("ZooDataBaseImplement.Models.Employee", null)
.WithMany("Preserves")
.HasForeignKey("EmployeeId");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Route", b =>
{
b.HasOne("ZooDataBaseImplement.Models.Client", "Client")
.WithMany("Routes")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.RoutePreserve", b =>
{
b.HasOne("ZooDataBaseImplement.Models.Preserve", "Preserve")
.WithMany("RoutePreserves")
.HasForeignKey("PreserveID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ZooDataBaseImplement.Models.Route", "Route")
.WithMany("Preserves")
.HasForeignKey("RouteID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Preserve");
b.Navigation("Route");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Client", b =>
{
b.Navigation("Routes");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Employee", b =>
{
b.Navigation("Preserves");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Preserve", b =>
{
b.Navigation("RoutePreserves");
});
modelBuilder.Entity("ZooDataBaseImplement.Models.Route", b =>
{
b.Navigation("Preserves");
});
#pragma warning restore 612, 618
}
}
}