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.
181 lines
11 KiB
181 lines
11 KiB
using System; |
|
using Microsoft.EntityFrameworkCore.Migrations; |
|
|
|
#nullable disable |
|
|
|
namespace AX.WebDrillServer.Migrations |
|
{ |
|
public partial class InitialCreate : Migration |
|
{ |
|
protected override void Up(MigrationBuilder migrationBuilder) |
|
{ |
|
migrationBuilder.CreateTable( |
|
name: "Organizations", |
|
columns: table => new |
|
{ |
|
Id = table.Column<string>(type: "text", unicode: false, nullable: false, comment: "ID"), |
|
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间"), |
|
CreatorId = table.Column<string>(type: "text", nullable: true, comment: "创建者 ID"), |
|
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最后修改时间"), |
|
LastModifierId = table.Column<string>(type: "text", nullable: true, comment: "最后修改者 ID"), |
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, comment: "是否删除"), |
|
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "删除时间"), |
|
DeleterId = table.Column<string>(type: "text", nullable: true, comment: "删除者 ID"), |
|
Code = table.Column<string>(type: "text", nullable: true, comment: "组织机构编码"), |
|
Name = table.Column<string>(type: "text", nullable: true, comment: "组织机构名称"), |
|
Level = table.Column<int>(type: "integer", nullable: false, comment: "组织机构级别"), |
|
Introductions = table.Column<string>(type: "text", nullable: true, comment: "组织机构说明") |
|
}, |
|
constraints: table => |
|
{ |
|
table.PrimaryKey("PK_Organizations", x => x.Id); |
|
}); |
|
|
|
migrationBuilder.CreateTable( |
|
name: "Premissions", |
|
columns: table => new |
|
{ |
|
Id = table.Column<string>(type: "text", unicode: false, nullable: false, comment: "ID"), |
|
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间"), |
|
CreatorId = table.Column<string>(type: "text", nullable: true, comment: "创建者 ID"), |
|
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最后修改时间"), |
|
LastModifierId = table.Column<string>(type: "text", nullable: true, comment: "最后修改者 ID"), |
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, comment: "是否删除"), |
|
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "删除时间"), |
|
DeleterId = table.Column<string>(type: "text", nullable: true, comment: "删除者 ID"), |
|
ParentId = table.Column<string>(type: "text", nullable: true, comment: "权限Id"), |
|
Name = table.Column<string>(type: "text", nullable: true, comment: "权限名称"), |
|
Introductions = table.Column<string>(type: "text", nullable: true, comment: "权限说明") |
|
}, |
|
constraints: table => |
|
{ |
|
table.PrimaryKey("PK_Premissions", x => x.Id); |
|
}); |
|
|
|
migrationBuilder.CreateTable( |
|
name: "Role_Premission", |
|
columns: table => new |
|
{ |
|
Id = table.Column<string>(type: "text", unicode: false, nullable: false, comment: "ID"), |
|
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间"), |
|
CreatorId = table.Column<string>(type: "text", nullable: true, comment: "创建者 ID"), |
|
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最后修改时间"), |
|
LastModifierId = table.Column<string>(type: "text", nullable: true, comment: "最后修改者 ID"), |
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, comment: "是否删除"), |
|
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "删除时间"), |
|
DeleterId = table.Column<string>(type: "text", nullable: true, comment: "删除者 ID"), |
|
RoleId = table.Column<string>(type: "text", nullable: true, comment: "角色Id"), |
|
PremissionId = table.Column<string>(type: "text", nullable: true, comment: "权限Id") |
|
}, |
|
constraints: table => |
|
{ |
|
table.PrimaryKey("PK_Role_Premission", x => x.Id); |
|
}); |
|
|
|
migrationBuilder.CreateTable( |
|
name: "Roles", |
|
columns: table => new |
|
{ |
|
Id = table.Column<string>(type: "text", unicode: false, nullable: false, comment: "ID"), |
|
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间"), |
|
CreatorId = table.Column<string>(type: "text", nullable: true, comment: "创建者 ID"), |
|
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最后修改时间"), |
|
LastModifierId = table.Column<string>(type: "text", nullable: true, comment: "最后修改者 ID"), |
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, comment: "是否删除"), |
|
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "删除时间"), |
|
DeleterId = table.Column<string>(type: "text", nullable: true, comment: "删除者 ID"), |
|
ParentId = table.Column<string>(type: "text", nullable: true, comment: "角色父级Id"), |
|
Name = table.Column<string>(type: "text", nullable: true, comment: "角色名称"), |
|
Introductions = table.Column<string>(type: "text", nullable: true, comment: "角色说明") |
|
}, |
|
constraints: table => |
|
{ |
|
table.PrimaryKey("PK_Roles", x => x.Id); |
|
}); |
|
|
|
migrationBuilder.CreateTable( |
|
name: "Users", |
|
columns: table => new |
|
{ |
|
Id = table.Column<string>(type: "text", unicode: false, nullable: false, comment: "ID"), |
|
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间"), |
|
CreatorId = table.Column<string>(type: "text", nullable: true, comment: "创建者 ID"), |
|
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最后修改时间"), |
|
LastModifierId = table.Column<string>(type: "text", nullable: true, comment: "最后修改者 ID"), |
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, comment: "是否删除"), |
|
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "删除时间"), |
|
DeleterId = table.Column<string>(type: "text", nullable: true, comment: "删除者 ID"), |
|
UserName = table.Column<string>(type: "text", nullable: true, comment: "用户名"), |
|
Password = table.Column<string>(type: "text", nullable: true, comment: "密码"), |
|
OrganizationId = table.Column<string>(type: "text", nullable: true, comment: "组织机构Id") |
|
}, |
|
constraints: table => |
|
{ |
|
table.PrimaryKey("PK_Users", x => x.Id); |
|
}); |
|
|
|
migrationBuilder.CreateTable( |
|
name: "User_Roles", |
|
columns: table => new |
|
{ |
|
Id = table.Column<string>(type: "text", unicode: false, nullable: false, comment: "ID"), |
|
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间"), |
|
CreatorId = table.Column<string>(type: "text", nullable: true, comment: "创建者 ID"), |
|
LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最后修改时间"), |
|
LastModifierId = table.Column<string>(type: "text", nullable: true, comment: "最后修改者 ID"), |
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, comment: "是否删除"), |
|
DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "删除时间"), |
|
DeleterId = table.Column<string>(type: "text", nullable: true, comment: "删除者 ID"), |
|
UserId = table.Column<string>(type: "text", nullable: false, comment: "用户Id"), |
|
RoleId = table.Column<string>(type: "text", nullable: false, comment: "角色Id") |
|
}, |
|
constraints: table => |
|
{ |
|
table.PrimaryKey("PK_User_Roles", x => x.Id); |
|
table.ForeignKey( |
|
name: "FK_User_Roles_Roles_RoleId", |
|
column: x => x.RoleId, |
|
principalTable: "Roles", |
|
principalColumn: "Id", |
|
onDelete: ReferentialAction.Cascade); |
|
table.ForeignKey( |
|
name: "FK_User_Roles_Users_UserId", |
|
column: x => x.UserId, |
|
principalTable: "Users", |
|
principalColumn: "Id", |
|
onDelete: ReferentialAction.Cascade); |
|
}); |
|
|
|
migrationBuilder.CreateIndex( |
|
name: "IX_User_Roles_RoleId", |
|
table: "User_Roles", |
|
column: "RoleId"); |
|
|
|
migrationBuilder.CreateIndex( |
|
name: "IX_User_Roles_UserId", |
|
table: "User_Roles", |
|
column: "UserId"); |
|
} |
|
|
|
protected override void Down(MigrationBuilder migrationBuilder) |
|
{ |
|
migrationBuilder.DropTable( |
|
name: "Organizations"); |
|
|
|
migrationBuilder.DropTable( |
|
name: "Premissions"); |
|
|
|
migrationBuilder.DropTable( |
|
name: "Role_Premission"); |
|
|
|
migrationBuilder.DropTable( |
|
name: "User_Roles"); |
|
|
|
migrationBuilder.DropTable( |
|
name: "Roles"); |
|
|
|
migrationBuilder.DropTable( |
|
name: "Users"); |
|
} |
|
} |
|
}
|
|
|