23 lines
942 B
SQL
23 lines
942 B
SQL
-- CreateTable: sos_sessions (Verlauf einer SOS-Session für DiGA-Doku)
|
|
CREATE TABLE IF NOT EXISTS rebreak.sos_sessions (
|
|
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
|
"user_id" UUID NOT NULL,
|
|
"started_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"ended_at" TIMESTAMPTZ,
|
|
"duration_sec" INTEGER,
|
|
"messages" JSONB NOT NULL DEFAULT '[]'::jsonb,
|
|
"gamesPlayed" JSONB NOT NULL DEFAULT '[]'::jsonb,
|
|
"breathing_count" INTEGER NOT NULL DEFAULT 0,
|
|
"was_overcome" BOOLEAN NOT NULL DEFAULT false,
|
|
"feedback_better" BOOLEAN,
|
|
"feedback_rating" INTEGER,
|
|
"feedback_text" TEXT,
|
|
"locale" TEXT,
|
|
|
|
CONSTRAINT "sos_sessions_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX IF NOT EXISTS "sos_sessions_user_id_started_at_idx"
|
|
ON rebreak.sos_sessions ("user_id", "started_at" DESC);
|