mirror of
https://github.com/Traceworks2023/nxtgauge-backend-rust.git
synced 2026-06-10 21:22:29 +00:00
17 lines
814 B
MySQL
17 lines
814 B
MySQL
|
|
-- Onboarding state per user per role
|
||
|
|
-- Tracks progress through the schema-driven onboarding form
|
||
|
|
CREATE TABLE IF NOT EXISTS onboarding_states (
|
||
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||
|
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||
|
|
role_id UUID NOT NULL REFERENCES roles(id) ON DELETE CASCADE,
|
||
|
|
status VARCHAR(20) NOT NULL DEFAULT 'NOT_STARTED', -- NOT_STARTED | IN_PROGRESS | COMPLETED
|
||
|
|
progress_json JSONB NOT NULL DEFAULT '{}',
|
||
|
|
completed_at TIMESTAMPTZ,
|
||
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||
|
|
);
|
||
|
|
|
||
|
|
-- One onboarding state record per user per role
|
||
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_onboarding_state_user_role
|
||
|
|
ON onboarding_states(user_id, role_id);
|