-- Hardware-only preview snapshots; no accounting status or invoice amount updates. CREATE TABLE IF NOT EXISTS hardware_intake_previews ( id UUID PRIMARY KEY, source_kind VARCHAR(20) NOT NULL CHECK(source_kind IN ('invoice','file')), source_id BIGINT NOT NULL, payload JSONB NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE UNIQUE INDEX IF NOT EXISTS uq_hardware_intake_unit ON hardware_assets ((hardware_specs->>'intake_unit_key')) WHERE hardware_specs->>'intake_unit_key' IS NOT NULL;