70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace PlumbingRepairDatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class WithClient : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "ClientId",
|
|
table: "Orders",
|
|
type: "integer",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
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.CreateIndex(
|
|
name: "IX_Orders_ClientId",
|
|
table: "Orders",
|
|
column: "ClientId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Orders_Clients_ClientId",
|
|
table: "Orders",
|
|
column: "ClientId",
|
|
principalTable: "Clients",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Orders_Clients_ClientId",
|
|
table: "Orders");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Clients");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Orders_ClientId",
|
|
table: "Orders");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "ClientId",
|
|
table: "Orders");
|
|
}
|
|
}
|
|
}
|