DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20220112104809_Refactor_UserRole.cs

60 lines
2.4 KiB
C#
Raw Normal View History

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Refactor_UserRole : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "id_parent",
table: "t_user_role");
migrationBuilder.CreateTable(
name: "t_relation_user_role_user_role",
columns: table => new
{
id_user_role = table.Column<int>(type: "integer", nullable: false),
id_include_user_role = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("t_relation_user_role_user_role_pk", x => new { x.id_user_role, x.id_include_user_role });
table.ForeignKey(
name: "FK_t_relation_user_role_user_role_t_user_role_id_include_user_~",
column: x => x.id_include_user_role,
principalTable: "t_user_role",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_t_relation_user_role_user_role_t_user_role_id_user_role",
column: x => x.id_user_role,
principalTable: "t_user_role",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
},
comment: "Отношение ролей к ролям");
migrationBuilder.CreateIndex(
name: "IX_t_relation_user_role_user_role_id_include_user_role",
table: "t_relation_user_role_user_role",
column: "id_include_user_role");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "t_relation_user_role_user_role");
migrationBuilder.AddColumn<int>(
name: "id_parent",
table: "t_user_role",
type: "integer",
nullable: true,
comment: "От какой роли унаследована данная роль");
}
}
}