212 lines
10 KiB
C#
212 lines
10 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace AccountMangement.Infrastructure.EFCore.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class SubAccount_SubTitleForClientPermission : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "SubAccountPermissionSubtitle1",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Title = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
|
Code = table.Column<int>(type: "int", maxLength: 15, nullable: false),
|
|
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubAccountPermissionSubtitle1", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubAccountRoles",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Title = table.Column<string>(type: "nvarchar(60)", maxLength: 60, nullable: true),
|
|
AccountId = table.Column<long>(type: "bigint", nullable: false),
|
|
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubAccountRoles", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubAccountPermissionSubtitle2",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Title = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
|
Code = table.Column<int>(type: "int", maxLength: 15, nullable: false),
|
|
ParentId = table.Column<long>(type: "bigint", nullable: false),
|
|
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubAccountPermissionSubtitle2", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_SubAccountPermissionSubtitle2_SubAccountPermissionSubtitle1_ParentId",
|
|
column: x => x.ParentId,
|
|
principalTable: "SubAccountPermissionSubtitle1",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubAccountRolePermissions",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
PermissionCode = table.Column<int>(type: "int", nullable: false),
|
|
SubAccountRoleId = table.Column<long>(type: "bigint", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubAccountRolePermissions", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_SubAccountRolePermissions_SubAccountRoles_SubAccountRoleId",
|
|
column: x => x.SubAccountRoleId,
|
|
principalTable: "SubAccountRoles",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubAccounts",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
PhoneNumber = table.Column<string>(type: "nvarchar(11)", maxLength: 11, nullable: false),
|
|
NationalCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
|
|
FName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
LName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
|
|
SubAccountRoleId = table.Column<long>(type: "bigint", nullable: false),
|
|
AccountId = table.Column<long>(type: "bigint", nullable: false),
|
|
Username = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
|
Password = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
|
|
VerifyCode = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
|
|
IsActive = table.Column<string>(type: "nvarchar(1)", maxLength: 1, nullable: false),
|
|
ProfilePhoto = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
|
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubAccounts", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_SubAccounts_SubAccountRoles_SubAccountRoleId",
|
|
column: x => x.SubAccountRoleId,
|
|
principalTable: "SubAccountRoles",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubAccountPermissionSubtitle3",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Title = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
|
Code = table.Column<int>(type: "int", maxLength: 15, nullable: false),
|
|
ParentId = table.Column<long>(type: "bigint", nullable: false),
|
|
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubAccountPermissionSubtitle3", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_SubAccountPermissionSubtitle3_SubAccountPermissionSubtitle2_ParentId",
|
|
column: x => x.ParentId,
|
|
principalTable: "SubAccountPermissionSubtitle2",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "SubAccountPermissionSubtitle4",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Title = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
|
Code = table.Column<int>(type: "int", maxLength: 15, nullable: false),
|
|
ParentId = table.Column<long>(type: "bigint", nullable: false),
|
|
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SubAccountPermissionSubtitle4", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_SubAccountPermissionSubtitle4_SubAccountPermissionSubtitle3_ParentId",
|
|
column: x => x.ParentId,
|
|
principalTable: "SubAccountPermissionSubtitle3",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SubAccountPermissionSubtitle2_ParentId",
|
|
table: "SubAccountPermissionSubtitle2",
|
|
column: "ParentId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SubAccountPermissionSubtitle3_ParentId",
|
|
table: "SubAccountPermissionSubtitle3",
|
|
column: "ParentId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SubAccountPermissionSubtitle4_ParentId",
|
|
table: "SubAccountPermissionSubtitle4",
|
|
column: "ParentId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SubAccountRolePermissions_SubAccountRoleId",
|
|
table: "SubAccountRolePermissions",
|
|
column: "SubAccountRoleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SubAccounts_SubAccountRoleId",
|
|
table: "SubAccounts",
|
|
column: "SubAccountRoleId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "SubAccountPermissionSubtitle4");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SubAccountRolePermissions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SubAccounts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SubAccountPermissionSubtitle3");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SubAccountRoles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SubAccountPermissionSubtitle2");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SubAccountPermissionSubtitle1");
|
|
}
|
|
}
|
|
}
|