Files
2026-07-13 16:49:13 +09:00

24 lines
943 B
SQL

CREATE TABLE "device_authorizations" (
"id" UUID NOT NULL,
"device_code_hash" TEXT NOT NULL,
"user_code" TEXT NOT NULL,
"status" TEXT NOT NULL DEFAULT 'PENDING',
"auth_user_id" UUID,
"account_email" TEXT,
"auth_user_name" TEXT,
"auth_user_role" TEXT,
"auth_user_roles" JSONB,
"device" JSONB,
"expires_at" TIMESTAMPTZ(3) NOT NULL,
"approved_at" TIMESTAMPTZ(3),
"consumed_at" TIMESTAMPTZ(3),
"created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMPTZ(3) NOT NULL,
CONSTRAINT "device_authorizations_pkey" PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX "device_authorizations_device_code_hash_key" ON "device_authorizations"("device_code_hash");
CREATE UNIQUE INDEX "device_authorizations_user_code_key" ON "device_authorizations"("user_code");
CREATE INDEX "device_authorizations_status_expires_at_idx" ON "device_authorizations"("status", "expires_at");