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(type: "integer", nullable: false), id_include_user_role = table.Column(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( name: "id_parent", table: "t_user_role", type: "integer", nullable: true, comment: "От какой роли унаследована данная роль"); } } }