157 lines
6.7 KiB
C#
157 lines
6.7 KiB
C#
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: "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: "Medications",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
MedicationName = table.Column<string>(type: "text", nullable: false),
|
|
Cost = table.Column<double>(type: "double precision", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Medications", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Medicines",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
MedicineName = table.Column<string>(type: "text", nullable: false),
|
|
Price = table.Column<double>(type: "double precision", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Medicines", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "MedicineMedications",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
MedicineId = table.Column<int>(type: "integer", nullable: false),
|
|
MedicationId = table.Column<int>(type: "integer", nullable: false),
|
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_MedicineMedications", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_MedicineMedications_Medications_MedicationId",
|
|
column: x => x.MedicationId,
|
|
principalTable: "Medications",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_MedicineMedications_Medicines_MedicineId",
|
|
column: x => x.MedicineId,
|
|
principalTable: "Medicines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Orders",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
MedicineId = table.Column<int>(type: "integer", nullable: false),
|
|
ClientId = table.Column<int>(type: "integer", nullable: false),
|
|
Count = table.Column<int>(type: "integer", nullable: false),
|
|
Sum = table.Column<double>(type: "double precision", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
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_Medicines_MedicineId",
|
|
column: x => x.MedicineId,
|
|
principalTable: "Medicines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MedicineMedications_MedicationId",
|
|
table: "MedicineMedications",
|
|
column: "MedicationId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MedicineMedications_MedicineId",
|
|
table: "MedicineMedications",
|
|
column: "MedicineId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Orders_ClientId",
|
|
table: "Orders",
|
|
column: "ClientId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Orders_MedicineId",
|
|
table: "Orders",
|
|
column: "MedicineId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "MedicineMedications");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Orders");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Medications");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Clients");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Medicines");
|
|
}
|
|
}
|
|
}
|