34 lines
1.3 KiB
SQL
34 lines
1.3 KiB
SQL
-- Revocable app sessions (customer app and sales-expert app).
|
|||
|
|
--
|
||
|
|
-- The admin panel got this in 20260925120000_admin_session; the app token family
|
||
|
|
-- had the same gap: a 30-day self-contained token that nothing could end early.
|
||
|
|
-- That matters more here, because the app's login is OTP-only — there is no
|
||
|
|
-- password an operator could change to cut access.
|
||
|
|
--
|
||
|
|
-- No foreign key on purpose: an app token's subject is a Customer for a customer
|
||
|
|
-- and an AdminUser for a sales expert (D21), which one FK cannot express.
|
||
|
|
CREATE TABLE "AppSession" (
|
||
|
|
"id" TEXT NOT NULL,
|
||
|
|
"jti" TEXT NOT NULL,
|
||
|
|
"subjectId" TEXT NOT NULL,
|
||
|
|
"subjectType" TEXT NOT NULL,
|
||
|
|
"mobile" TEXT,
|
||
|
|
"iamSessionId" TEXT,
|
||
|
|
"iamSub" TEXT,
|
||
|
|
"ipAddress" TEXT,
|
||
|
|
"userAgent" TEXT,
|
||
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||
|
|
"expiresAt" TIMESTAMP(3),
|
||
|
|
"lastSeenAt" TIMESTAMP(3),
|
||
|
|
"revokedAt" TIMESTAMP(3),
|
||
|
|
"revokedReason" TEXT,
|
||
|
|
|
||
|
|
CONSTRAINT "AppSession_pkey" PRIMARY KEY ("id")
|
||
|
|
);
|
||
|
|
|
||
|
|
CREATE UNIQUE INDEX "AppSession_jti_key" ON "AppSession"("jti");
|
||
|
|
CREATE INDEX "AppSession_subjectId_idx" ON "AppSession"("subjectId");
|
||
|
|
CREATE INDEX "AppSession_iamSessionId_idx" ON "AppSession"("iamSessionId");
|
||
|
|
CREATE INDEX "AppSession_iamSub_idx" ON "AppSession"("iamSub");
|
||
|
|
CREATE INDEX "AppSession_expiresAt_idx" ON "AppSession"("expiresAt");
|