Миграция, тестики и создание отчета

This commit is contained in:
Алексей Тихоненков 2024-05-19 03:04:15 +04:00
parent 909bd32b63
commit b64017dc46
3 changed files with 568 additions and 0 deletions

View File

@ -0,0 +1,209 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using StorageCompanyDatabaseImplement;
#nullable disable
namespace StorageCompanyDatabaseImplement.Migrations
{
[DbContext(typeof(StorageCompanyDatabase))]
[Migration("20240518230318_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("StorageCompanyDatabaseImplement.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("StorageCompanyDatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ProductNum")
.HasColumnType("integer");
b.Property<int>("ProductType")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Provider", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ProviderFIO")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Providers");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Sale", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<int>("ProductId")
.HasColumnType("integer");
b.Property<int>("SaleNum")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ProductId");
b.ToTable("Sales");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Supply", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ProductId")
.HasColumnType("integer");
b.Property<int>("ProviderId")
.HasColumnType("integer");
b.Property<int>("SupplyNum")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("ProviderId");
b.ToTable("Supplys");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Sale", b =>
{
b.HasOne("StorageCompanyDatabaseImplement.Models.Client", "Client")
.WithMany("Sales")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("StorageCompanyDatabaseImplement.Models.Product", "Product")
.WithMany("Sales")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Product");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Supply", b =>
{
b.HasOne("StorageCompanyDatabaseImplement.Models.Product", "Product")
.WithMany("Supplys")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("StorageCompanyDatabaseImplement.Models.Provider", "Provider")
.WithMany("Supplys")
.HasForeignKey("ProviderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Provider");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Client", b =>
{
b.Navigation("Sales");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Product", b =>
{
b.Navigation("Sales");
b.Navigation("Supplys");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Provider", b =>
{
b.Navigation("Supplys");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,153 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace StorageCompanyDatabaseImplement.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: "Products",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ProductName = table.Column<string>(type: "text", nullable: false),
ProductNum = table.Column<int>(type: "integer", nullable: false),
ProductType = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Providers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ProviderFIO = 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_Providers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Sales",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientId = table.Column<int>(type: "integer", nullable: false),
ProductId = table.Column<int>(type: "integer", nullable: false),
SaleNum = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sales", x => x.Id);
table.ForeignKey(
name: "FK_Sales_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Sales_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Supplys",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ProviderId = table.Column<int>(type: "integer", nullable: false),
ProductId = table.Column<int>(type: "integer", nullable: false),
SupplyNum = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Supplys", x => x.Id);
table.ForeignKey(
name: "FK_Supplys_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Supplys_Providers_ProviderId",
column: x => x.ProviderId,
principalTable: "Providers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Sales_ClientId",
table: "Sales",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Sales_ProductId",
table: "Sales",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Supplys_ProductId",
table: "Supplys",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Supplys_ProviderId",
table: "Supplys",
column: "ProviderId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Sales");
migrationBuilder.DropTable(
name: "Supplys");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "Providers");
}
}
}

View File

@ -0,0 +1,206 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using StorageCompanyDatabaseImplement;
#nullable disable
namespace StorageCompanyDatabaseImplement.Migrations
{
[DbContext(typeof(StorageCompanyDatabase))]
partial class StorageCompanyDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("StorageCompanyDatabaseImplement.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("StorageCompanyDatabaseImplement.Models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ProductNum")
.HasColumnType("integer");
b.Property<int>("ProductType")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Products");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Provider", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ProviderFIO")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Providers");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Sale", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<int>("ProductId")
.HasColumnType("integer");
b.Property<int>("SaleNum")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ProductId");
b.ToTable("Sales");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Supply", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ProductId")
.HasColumnType("integer");
b.Property<int>("ProviderId")
.HasColumnType("integer");
b.Property<int>("SupplyNum")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("ProviderId");
b.ToTable("Supplys");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Sale", b =>
{
b.HasOne("StorageCompanyDatabaseImplement.Models.Client", "Client")
.WithMany("Sales")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("StorageCompanyDatabaseImplement.Models.Product", "Product")
.WithMany("Sales")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Product");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Supply", b =>
{
b.HasOne("StorageCompanyDatabaseImplement.Models.Product", "Product")
.WithMany("Supplys")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("StorageCompanyDatabaseImplement.Models.Provider", "Provider")
.WithMany("Supplys")
.HasForeignKey("ProviderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Product");
b.Navigation("Provider");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Client", b =>
{
b.Navigation("Sales");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Product", b =>
{
b.Navigation("Sales");
b.Navigation("Supplys");
});
modelBuilder.Entity("StorageCompanyDatabaseImplement.Models.Provider", b =>
{
b.Navigation("Supplys");
});
#pragma warning restore 612, 618
}
}
}