You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/samples/MicroserviceDemo/applications/AuthServer.Host/Migrations/20200525053551_Added_Organi...

128 lines
5.9 KiB

using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace AuthServer.Host.Migrations
{
public partial class Added_OrganizationUnits : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AbpOrganizationUnits",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
LastModificationTime = table.Column<DateTime>(nullable: true),
LastModifierId = table.Column<Guid>(nullable: true),
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(nullable: true),
DeletionTime = table.Column<DateTime>(nullable: true),
TenantId = table.Column<Guid>(nullable: true),
ParentId = table.Column<Guid>(nullable: true),
Code = table.Column<string>(maxLength: 95, nullable: false),
DisplayName = table.Column<string>(maxLength: 128, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id);
table.ForeignKey(
name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId",
column: x => x.ParentId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AbpOrganizationUnitRoles",
columns: table => new
{
RoleId = table.Column<Guid>(nullable: false),
OrganizationUnitId = table.Column<Guid>(nullable: false),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
TenantId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId });
table.ForeignKey(
name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId",
column: x => x.OrganizationUnitId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId",
column: x => x.RoleId,
principalTable: "AbpRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserOrganizationUnits",
columns: table => new
{
UserId = table.Column<Guid>(nullable: false),
OrganizationUnitId = table.Column<Guid>(nullable: false),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
TenantId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId });
table.ForeignKey(
name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId",
column: x => x.OrganizationUnitId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId",
table: "AbpOrganizationUnitRoles",
columns: new[] { "RoleId", "OrganizationUnitId" });
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnits_Code",
table: "AbpOrganizationUnits",
column: "Code");
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnits_ParentId",
table: "AbpOrganizationUnits",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId",
table: "AbpUserOrganizationUnits",
columns: new[] { "UserId", "OrganizationUnitId" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AbpOrganizationUnitRoles");
migrationBuilder.DropTable(
name: "AbpUserOrganizationUnits");
migrationBuilder.DropTable(
name: "AbpOrganizationUnits");
}
}
}