Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / db/migrations/0042_vendor_intelligence.sql |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | db/migrations/0042_vendor_intelligence.sql |
| Original SHA-256 | ec8ec80c43c1a8a6bf02ebc200336cf0dbe8c2f4ec777e12dd6344a79865b35f |
| Git blob SHA | 24f42e83d08855871fe9c20e43b9e7673ce987b0 |
| Reading-copy SHA-256 | ec8ec80c43c1a8a6bf02ebc200336cf0dbe8c2f4ec777e12dd6344a79865b35f |
Every recorded occurrence
These 5 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / db/migrations/0042_vendor_intelligence.sql | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / db/migrations/0042_vendor_intelligence.sql | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / db/migrations/0042_vendor_intelligence.sql | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / db/migrations/0042_vendor_intelligence.sql | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / db/migrations/0042_vendor_intelligence.sql | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓76 lines · 5.3 KB
-- +goose Up
-- Phase 2 Vendor Intelligence: the staffing vendor performance data model. Two tenant scoped RLS tables so the
-- platform can measure a staffing vendor or subcontractor's performance (fill rate, time to submit, submit to
-- interview, and the quality of the candidates they submit) WITHOUT ever rescoring a person. The quality signal
-- is the ALREADY COMPUTED frozen v1.4.0 engine band (candidate_evaluations.band) of the candidates a vendor
-- submitted, read on a join, never recomputed. The frozen engine stays the ONLY per candidate scorer. Any per
-- vendor per band headcount surfaced from this data is k=10 small cell suppressed at the AI layer so a sub k
-- vendor band never re identifies an individual.
-- ---------------------------------------------------------------------------
-- staffing_vendors: the org's registry of the staffing firms and subcontractors that submit candidates. Tenant
-- scoped, RLS forced. UEI is a natural government business key but a staffing firm may have none, so it is
-- nullable via a default empty string with a partial unique index (one row per non empty UEI per org). The
-- composite (organization_id, id) is the FK target for vendor_submissions.
-- ---------------------------------------------------------------------------
CREATE TABLE staffing_vendors (
organization_id uuid NOT NULL REFERENCES organizations(id),
id uuid NOT NULL DEFAULT gen_random_uuid(),
name text NOT NULL,
uei text NOT NULL DEFAULT '',
vendor_type text NOT NULL DEFAULT 'staffing_firm'
CHECK (vendor_type IN ('staffing_firm', 'subcontractor', 'direct', 'prime')),
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (organization_id, id)
);
CREATE UNIQUE INDEX uq_staffing_vendors_org_uei ON staffing_vendors (organization_id, uei) WHERE uei <> '';
CREATE INDEX idx_staffing_vendors_org ON staffing_vendors (organization_id, created_at DESC);
ALTER TABLE staffing_vendors ENABLE ROW LEVEL SECURITY;
ALTER TABLE staffing_vendors FORCE ROW LEVEL SECURITY;
CREATE POLICY staffing_vendors_isolation ON staffing_vendors
USING (organization_id = NULLIF(current_setting('app.current_org_id', true), '')::uuid)
WITH CHECK (organization_id = NULLIF(current_setting('app.current_org_id', true), '')::uuid);
GRANT SELECT, INSERT, UPDATE, DELETE ON staffing_vendors TO missionmatch_app;
-- ---------------------------------------------------------------------------
-- vendor_submissions: the append friendly fact of a vendor submitting a candidate for a requirement, and the
-- lifecycle status the org records (submitted, then interviewed, placed, or rejected). One row per (vendor,
-- candidate, requirement) per org. Composite FKs carry organization_id so a submission can never reference a
-- vendor, candidate, or requirement in another tenant. It does NOT foreign key to candidate_evaluations: a
-- submission may exist before the candidate is screened, so the quality read is a LEFT JOIN on the triple, not
-- a hard reference. time to submit is derived at read time from the requirement's created_at, no stored column.
-- ---------------------------------------------------------------------------
CREATE TABLE vendor_submissions (
organization_id uuid NOT NULL,
vendor_id uuid NOT NULL,
candidate_id uuid NOT NULL,
requirement_id uuid NOT NULL,
submitted_at timestamptz NOT NULL DEFAULT now(),
decided_at timestamptz, -- when the status moved off submitted; null while pending
status text NOT NULL DEFAULT 'submitted'
CHECK (status IN ('submitted', 'interviewed', 'placed', 'rejected')),
created_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (organization_id, vendor_id, candidate_id, requirement_id),
FOREIGN KEY (organization_id, vendor_id) REFERENCES staffing_vendors (organization_id, id) ON DELETE CASCADE,
FOREIGN KEY (organization_id, candidate_id) REFERENCES candidates (organization_id, id) ON DELETE CASCADE,
FOREIGN KEY (organization_id, requirement_id) REFERENCES requirements (organization_id, id) ON DELETE CASCADE
);
CREATE INDEX idx_vendor_submissions_org ON vendor_submissions (organization_id, submitted_at DESC);
CREATE INDEX idx_vendor_submissions_org_vendor ON vendor_submissions (organization_id, vendor_id, requirement_id);
ALTER TABLE vendor_submissions ENABLE ROW LEVEL SECURITY;
ALTER TABLE vendor_submissions FORCE ROW LEVEL SECURITY;
CREATE POLICY vendor_submissions_isolation ON vendor_submissions
USING (organization_id = NULLIF(current_setting('app.current_org_id', true), '')::uuid)
WITH CHECK (organization_id = NULLIF(current_setting('app.current_org_id', true), '')::uuid);
-- The app records a submission (INSERT), advances its status (UPDATE), and reads it. It never deletes a
-- submission: a submission is an append friendly performance fact, kept even after the vendor row is gone via
-- the ON DELETE CASCADE (a deliberate cascade when a vendor is removed, not an app DELETE of a single fact).
GRANT SELECT, INSERT, UPDATE ON vendor_submissions TO missionmatch_app;
-- +goose Down
DROP TABLE IF EXISTS vendor_submissions;
DROP TABLE IF EXISTS staffing_vendors;