feat(api): add M5 coverage controls and frontend spec
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user