178 lines
7.0 KiB
C#
178 lines
7.0 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Brizco.Repository.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class editShiftPlanUser : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShiftPlanUsers_Users_ApplicationUserId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PositionUsers",
|
|
schema: "public");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "ApplicationUserId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
newName: "UserId");
|
|
|
|
migrationBuilder.RenameIndex(
|
|
name: "IX_ShiftPlanUsers_ApplicationUserId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
newName: "IX_ShiftPlanUsers_UserId");
|
|
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "PositionId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
type: "uuid",
|
|
nullable: false,
|
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShiftPlanUsers_PositionId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
column: "PositionId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShiftPlanUsers_Positions_PositionId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
column: "PositionId",
|
|
principalSchema: "public",
|
|
principalTable: "Positions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShiftPlanUsers_Users_UserId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
column: "UserId",
|
|
principalSchema: "public",
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShiftPlanUsers_Positions_PositionId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_ShiftPlanUsers_Users_UserId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_ShiftPlanUsers_PositionId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "PositionId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "UserId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
newName: "ApplicationUserId");
|
|
|
|
migrationBuilder.RenameIndex(
|
|
name: "IX_ShiftPlanUsers_UserId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
newName: "IX_ShiftPlanUsers_ApplicationUserId");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PositionUsers",
|
|
schema: "public",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ApplicationUserId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PositionId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ShiftPlanId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
CreatedBy = table.Column<string>(type: "text", nullable: false),
|
|
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
|
|
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
ModifiedBy = table.Column<string>(type: "text", nullable: false),
|
|
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
RemovedBy = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PositionUsers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PositionUsers_Positions_PositionId",
|
|
column: x => x.PositionId,
|
|
principalSchema: "public",
|
|
principalTable: "Positions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_PositionUsers_ShiftPlans_ShiftPlanId",
|
|
column: x => x.ShiftPlanId,
|
|
principalSchema: "public",
|
|
principalTable: "ShiftPlans",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_PositionUsers_Users_ApplicationUserId",
|
|
column: x => x.ApplicationUserId,
|
|
principalSchema: "public",
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PositionUsers_ApplicationUserId",
|
|
schema: "public",
|
|
table: "PositionUsers",
|
|
column: "ApplicationUserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PositionUsers_PositionId",
|
|
schema: "public",
|
|
table: "PositionUsers",
|
|
column: "PositionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PositionUsers_ShiftPlanId",
|
|
schema: "public",
|
|
table: "PositionUsers",
|
|
column: "ShiftPlanId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_ShiftPlanUsers_Users_ApplicationUserId",
|
|
schema: "public",
|
|
table: "ShiftPlanUsers",
|
|
column: "ApplicationUserId",
|
|
principalSchema: "public",
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
}
|
|
}
|