-- CreateEnum CREATE TYPE "Role" AS ENUM ('ADMIN', 'USER', 'PENDING'); -- AlterTable ALTER TABLE "User" ADD COLUMN "role" "Role" NOT NULL DEFAULT 'USER'; -- Backfill: on installs that already have users, the earliest-created -- account becomes ADMIN -- consistent with "the first person to sign up -- is the administrator" for accounts that predate this migration. UPDATE "User" SET "role" = 'ADMIN' WHERE "id" = (SELECT "id" FROM "User" ORDER BY "createdAt" ASC LIMIT 1);