mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-23 19:42:51 +01:00
199 lines
7.5 KiB
C#
199 lines
7.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Phantom.Controller.Database.Postgres.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class ReplaceIdentity2 : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Roles",
|
|
schema: "identity",
|
|
columns: table => new
|
|
{
|
|
RoleGuid = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Roles", x => x.RoleGuid);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
schema: "identity",
|
|
columns: table => new
|
|
{
|
|
UserGuid = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
PasswordHash = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.UserGuid);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RolePermissions",
|
|
schema: "identity",
|
|
columns: table => new
|
|
{
|
|
RoleGuid = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PermissionId = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_RolePermissions", x => new { x.RoleGuid, x.PermissionId });
|
|
table.ForeignKey(
|
|
name: "FK_RolePermissions_Permissions_PermissionId",
|
|
column: x => x.PermissionId,
|
|
principalSchema: "identity",
|
|
principalTable: "Permissions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_RolePermissions_Roles_RoleGuid",
|
|
column: x => x.RoleGuid,
|
|
principalSchema: "identity",
|
|
principalTable: "Roles",
|
|
principalColumn: "RoleGuid",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserPermissions",
|
|
schema: "identity",
|
|
columns: table => new
|
|
{
|
|
UserGuid = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PermissionId = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_UserPermissions", x => new { x.UserGuid, x.PermissionId });
|
|
table.ForeignKey(
|
|
name: "FK_UserPermissions_Permissions_PermissionId",
|
|
column: x => x.PermissionId,
|
|
principalSchema: "identity",
|
|
principalTable: "Permissions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UserPermissions_Users_UserGuid",
|
|
column: x => x.UserGuid,
|
|
principalSchema: "identity",
|
|
principalTable: "Users",
|
|
principalColumn: "UserGuid",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserRoles",
|
|
schema: "identity",
|
|
columns: table => new
|
|
{
|
|
UserGuid = table.Column<Guid>(type: "uuid", nullable: false),
|
|
RoleGuid = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_UserRoles", x => new { x.UserGuid, x.RoleGuid });
|
|
table.ForeignKey(
|
|
name: "FK_UserRoles_Roles_RoleGuid",
|
|
column: x => x.RoleGuid,
|
|
principalSchema: "identity",
|
|
principalTable: "Roles",
|
|
principalColumn: "RoleGuid",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UserRoles_Users_UserGuid",
|
|
column: x => x.UserGuid,
|
|
principalSchema: "identity",
|
|
principalTable: "Users",
|
|
principalColumn: "UserGuid",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AuditLog_UserGuid",
|
|
schema: "system",
|
|
table: "AuditLog",
|
|
column: "UserGuid");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RolePermissions_PermissionId",
|
|
schema: "identity",
|
|
table: "RolePermissions",
|
|
column: "PermissionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserPermissions_PermissionId",
|
|
schema: "identity",
|
|
table: "UserPermissions",
|
|
column: "PermissionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserRoles_RoleGuid",
|
|
schema: "identity",
|
|
table: "UserRoles",
|
|
column: "RoleGuid");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_Name",
|
|
schema: "identity",
|
|
table: "Users",
|
|
column: "Name",
|
|
unique: true);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_AuditLog_Users_UserGuid",
|
|
schema: "system",
|
|
table: "AuditLog",
|
|
column: "UserGuid",
|
|
principalSchema: "identity",
|
|
principalTable: "Users",
|
|
principalColumn: "UserGuid",
|
|
onDelete: ReferentialAction.SetNull);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_AuditLog_Users_UserGuid",
|
|
schema: "system",
|
|
table: "AuditLog");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "RolePermissions",
|
|
schema: "identity");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserPermissions",
|
|
schema: "identity");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserRoles",
|
|
schema: "identity");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Roles",
|
|
schema: "identity");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users",
|
|
schema: "identity");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_AuditLog_UserGuid",
|
|
schema: "system",
|
|
table: "AuditLog");
|
|
}
|
|
}
|
|
}
|