using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace VeterinaryClinicDatabaseImplement.Migrations
{
///
public partial class InitialCreate : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ClientFIO = table.Column(type: "text", nullable: false),
Email = table.Column(type: "text", nullable: false),
Password = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Medications",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
MedicationName = table.Column(type: "text", nullable: false),
Cost = table.Column(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Medications", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Medicines",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
MedicineName = table.Column(type: "text", nullable: false),
Price = table.Column(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Medicines", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MedicineMedications",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
MedicineId = table.Column(type: "integer", nullable: false),
MedicationId = table.Column(type: "integer", nullable: false),
Count = table.Column(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(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
MedicineId = table.Column(type: "integer", nullable: false),
ClientId = table.Column(type: "integer", nullable: false),
Count = table.Column(type: "integer", nullable: false),
Sum = table.Column(type: "double precision", nullable: false),
Status = table.Column(type: "integer", nullable: false),
DateCreate = table.Column(type: "timestamp with time zone", nullable: false),
DateImplement = table.Column(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");
}
///
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");
}
}
}