43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|