feat(api): complete unified v2 mobile surface
This commit is contained in:
44
backend/command-api/sql/v2/003_v2_mobile_workflows.sql
Normal file
44
backend/command-api/sql/v2/003_v2_mobile_workflows.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
CREATE TABLE IF NOT EXISTS emergency_contacts (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
||||
staff_id UUID NOT NULL REFERENCES staffs(id) ON DELETE CASCADE,
|
||||
full_name TEXT NOT NULL,
|
||||
phone TEXT NOT NULL,
|
||||
relationship_type TEXT NOT NULL,
|
||||
is_primary BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_emergency_contacts_staff
|
||||
ON emergency_contacts (staff_id, created_at DESC);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_emergency_contacts_primary_staff
|
||||
ON emergency_contacts (staff_id)
|
||||
WHERE is_primary = TRUE;
|
||||
|
||||
ALTER TABLE assignments
|
||||
DROP CONSTRAINT IF EXISTS assignments_status_check;
|
||||
|
||||
ALTER TABLE assignments
|
||||
ADD CONSTRAINT assignments_status_check
|
||||
CHECK (status IN ('ASSIGNED', 'ACCEPTED', 'SWAP_REQUESTED', 'CHECKED_IN', 'CHECKED_OUT', 'COMPLETED', 'CANCELLED', 'NO_SHOW'));
|
||||
|
||||
ALTER TABLE verification_jobs
|
||||
ADD COLUMN IF NOT EXISTS owner_user_id TEXT REFERENCES users(id) ON DELETE SET NULL,
|
||||
ADD COLUMN IF NOT EXISTS subject_type TEXT,
|
||||
ADD COLUMN IF NOT EXISTS subject_id TEXT;
|
||||
|
||||
ALTER TABLE staff_documents
|
||||
ADD COLUMN IF NOT EXISTS verification_job_id UUID REFERENCES verification_jobs(id) ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE certificates
|
||||
ADD COLUMN IF NOT EXISTS file_uri TEXT,
|
||||
ADD COLUMN IF NOT EXISTS verification_job_id UUID REFERENCES verification_jobs(id) ON DELETE SET NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_verification_jobs_owner
|
||||
ON verification_jobs (owner_user_id, created_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_verification_jobs_subject
|
||||
ON verification_jobs (subject_type, subject_id, created_at DESC);
|
||||
Reference in New Issue
Block a user