feat(api): add M5 coverage controls and frontend spec

This commit is contained in:
zouantchaw
2026-03-18 08:18:50 +01:00
parent 008dd7efb1
commit 32f6cd55c8
14 changed files with 894 additions and 8 deletions

View File

@@ -0,0 +1,41 @@
CREATE TABLE IF NOT EXISTS staff_blocks (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
business_id UUID NOT NULL REFERENCES businesses(id) ON DELETE CASCADE,
staff_id UUID NOT NULL REFERENCES staffs(id) ON DELETE CASCADE,
created_by_user_id TEXT REFERENCES users(id) ON DELETE SET NULL,
reason TEXT,
issue_flags JSONB NOT NULL DEFAULT '[]'::jsonb,
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_staff_blocks_business_staff
ON staff_blocks (business_id, staff_id);
CREATE INDEX IF NOT EXISTS idx_staff_blocks_business_created_at
ON staff_blocks (business_id, created_at DESC);
CREATE TABLE IF NOT EXISTS staff_benefit_history (
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,
benefit_id UUID REFERENCES staff_benefits(id) ON DELETE SET NULL,
benefit_type TEXT NOT NULL,
title TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'ACTIVE',
effective_at TIMESTAMPTZ NOT NULL,
ended_at TIMESTAMPTZ,
tracked_hours INTEGER NOT NULL DEFAULT 0,
target_hours INTEGER,
notes TEXT,
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_staff_benefit_history_staff_effective_at
ON staff_benefit_history (staff_id, effective_at DESC);
CREATE INDEX IF NOT EXISTS idx_staff_benefit_history_tenant_benefit_type
ON staff_benefit_history (tenant_id, benefit_type, effective_at DESC);