25 lines
901 B
C#
25 lines
901 B
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Backend.Data;
|
|
|
|
public static class SessionBootstrapper
|
|
{
|
|
public static Task EnsureAsync(AwardsDbContext db) =>
|
|
db.Database.ExecuteSqlRawAsync(
|
|
"""
|
|
CREATE TABLE IF NOT EXISTS "UserSessions" (
|
|
"Id" uuid NOT NULL PRIMARY KEY,
|
|
"SessionToken" character varying(120) NOT NULL,
|
|
"TwitchUserId" character varying(120) NOT NULL,
|
|
"DisplayName" character varying(120) NOT NULL,
|
|
"Role" character varying(40) NOT NULL,
|
|
"CreatedAt" timestamp with time zone NOT NULL,
|
|
"LastSeenAt" timestamp with time zone NOT NULL,
|
|
"IsActive" boolean NOT NULL
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "IX_UserSessions_SessionToken"
|
|
ON "UserSessions" ("SessionToken");
|
|
""");
|
|
}
|