Add admin roles, user management, and campaign deletion
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RpgRoller.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddAuthorizationRolesAndCampaignDeletion : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Roles",
|
||||
table: "Users",
|
||||
type: "TEXT",
|
||||
maxLength: 256,
|
||||
nullable: false,
|
||||
defaultValue: "admin");
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "CampaignId",
|
||||
table: "Characters",
|
||||
type: "TEXT",
|
||||
nullable: true,
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
UPDATE Users
|
||||
SET Roles = 'admin'
|
||||
WHERE Roles IS NULL OR TRIM(Roles) = '';
|
||||
""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Roles",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "CampaignId",
|
||||
table: "Characters",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "TEXT",
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user