using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace MTWorkHR.Identity.Migrations
{
///
public partial class updateUser : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "FavoriteName",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn(
name: "IncomeTaxValue",
table: "AspNetUsers",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn(
name: "JobTitle",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn(
name: "PassportNumber",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn(
name: "QualificationId",
table: "AspNetUsers",
type: "int",
nullable: true);
migrationBuilder.AddColumn(
name: "TaxNumber",
table: "AspNetUsers",
type: "decimal(18,2)",
nullable: true);
migrationBuilder.AddColumn(
name: "University",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.CreateTable(
name: "AttachmentTypes",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
NameAr = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false),
NameEn = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false),
IsRequired = table.Column(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AttachmentTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserAddress",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CreateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true),
UpdateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true),
CreateDate = table.Column(type: "datetime2", nullable: false),
UpdateDate = table.Column(type: "datetime2", nullable: true),
UserId = table.Column(type: "nvarchar(450)", nullable: false),
CountryId = table.Column(type: "int", nullable: false),
City = table.Column(type: "nvarchar(max)", nullable: false),
PostalCode = table.Column(type: "nvarchar(max)", nullable: false),
AddressDesc = table.Column(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserAddress", x => x.Id);
table.ForeignKey(
name: "FK_UserAddress_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserAttachments",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CreateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true),
UpdateUser = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: true),
CreateDate = table.Column(type: "datetime2", nullable: false),
UpdateDate = table.Column(type: "datetime2", nullable: true),
UserId = table.Column(type: "nvarchar(450)", nullable: false),
AttachmentTypeId = table.Column(type: "bigint", nullable: false),
FileName = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false),
OriginalName = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserAttachments", x => x.Id);
table.ForeignKey(
name: "FK_UserAttachments_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserAttachments_AttachmentTypes_AttachmentTypeId",
column: x => x.AttachmentTypeId,
principalTable: "AttachmentTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
columns: new[] { "FavoriteName", "IncomeTaxValue", "JobTitle", "PassportNumber", "QualificationId", "TaxNumber", "University" },
values: new object[] { null, 1m, null, "1234567", 1, 111m, null });
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
columns: new[] { "FavoriteName", "IncomeTaxValue", "JobTitle", "PassportNumber", "QualificationId", "TaxNumber", "University" },
values: new object[] { null, 100m, null, "7654321001010", 1, 222m, null });
migrationBuilder.InsertData(
table: "AttachmentTypes",
columns: new[] { "Id", "IsRequired", "NameAr", "NameEn" },
values: new object[,]
{
{ 1L, false, "السيرة الذاتية", "CV" },
{ 2L, false, "الهوية", "Identification" }
});
migrationBuilder.CreateIndex(
name: "IX_UserAddress_UserId",
table: "UserAddress",
column: "UserId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UserAttachments_AttachmentTypeId",
table: "UserAttachments",
column: "AttachmentTypeId");
migrationBuilder.CreateIndex(
name: "IX_UserAttachments_UserId",
table: "UserAttachments",
column: "UserId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserAddress");
migrationBuilder.DropTable(
name: "UserAttachments");
migrationBuilder.DropTable(
name: "AttachmentTypes");
migrationBuilder.DropColumn(
name: "FavoriteName",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "IncomeTaxValue",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "JobTitle",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "PassportNumber",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "QualificationId",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "TaxNumber",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "University",
table: "AspNetUsers");
}
}
}