Add owner role and admin management controls
This commit is contained in:
42
Data/Migrations/20260208175912_AddOwnerRole.cs
Normal file
42
Data/Migrations/20260208175912_AddOwnerRole.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace GameList.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddOwnerRole : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsOwner",
|
||||
table: "Players",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.Sql(
|
||||
"""
|
||||
UPDATE Players
|
||||
SET IsOwner = 1
|
||||
WHERE Id = (
|
||||
SELECT Id
|
||||
FROM Players
|
||||
WHERE IsAdmin = 1
|
||||
ORDER BY CreatedAt, Id
|
||||
LIMIT 1
|
||||
);
|
||||
""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsOwner",
|
||||
table: "Players");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user