CREATE INDEX IF NOT EXISTS checkins_tenant_phase_created_idx ON checkins (tenant_id, phase, created_at DESC);
CREATE INDEX IF NOT EXISTS checkins_tenant_department_aggregate_idx ON employees (tenant_id, department, status);

ALTER TABLE checkins
    ADD COLUMN IF NOT EXISTS summary_score DECIMAL(5,2),
    ADD COLUMN IF NOT EXISTS processed_at TIMESTAMP;

GRANT SELECT, INSERT, UPDATE ON checkins TO diwall_core_app;
