70 lines
3.3 KiB
C#
70 lines
3.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace MinAttest.Infrastructure.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddEmployerUser : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "EmployerUsers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
EmployerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|
ExternalObjectId = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
|
|
Role = table.Column<int>(type: "int", nullable: false),
|
|
PeriodEnd = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
.Annotation("SqlServer:TemporalIsPeriodEndColumn", true),
|
|
PeriodStart = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
.Annotation("SqlServer:TemporalIsPeriodStartColumn", true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_EmployerUsers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_EmployerUsers_Employers_EmployerId",
|
|
column: x => x.EmployerId,
|
|
principalTable: "Employers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("SqlServer:IsTemporal", true)
|
|
.Annotation("SqlServer:TemporalHistoryTableName", "EmployerUsersHistory")
|
|
.Annotation("SqlServer:TemporalHistoryTableSchema", null)
|
|
.Annotation("SqlServer:TemporalPeriodEndColumnName", "PeriodEnd")
|
|
.Annotation("SqlServer:TemporalPeriodStartColumnName", "PeriodStart");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_EmployerUsers_EmployerId",
|
|
table: "EmployerUsers",
|
|
column: "EmployerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_EmployerUsers_ExternalObjectId",
|
|
table: "EmployerUsers",
|
|
column: "ExternalObjectId",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "EmployerUsers")
|
|
.Annotation("SqlServer:IsTemporal", true)
|
|
.Annotation("SqlServer:TemporalHistoryTableName", "EmployerUsersHistory")
|
|
.Annotation("SqlServer:TemporalHistoryTableSchema", null)
|
|
.Annotation("SqlServer:TemporalPeriodEndColumnName", "PeriodEnd")
|
|
.Annotation("SqlServer:TemporalPeriodStartColumnName", "PeriodStart");
|
|
}
|
|
}
|
|
}
|