-- RPartStore (rpartstore.renault.com, Renault Group dealer portal) VIN-decode -- fallback cache (feature-flagged: RPARTSTORE_ENABLED). One row per VIN. The -- rpartstore-decode BullMQ job asks the RPartStore BFF (STOMP over WebSocket) -- for Renault/Dacia VINs the normal chain (pcat/PL24/emex) can't identify, then -- matches the decoded model to an EXISTING PL24 catalog_vehicle. RPartStore is -- ONLY a decode oracle here — parts are served from PL24's existing catalog. -- status: 'pending' | 'decoded' | 'not_found' | 'capped' | 'failed'. CREATE TABLE IF NOT EXISTS "rpartstore_decodes" ( "vin" text PRIMARY KEY NOT NULL, "status" text DEFAULT 'pending' NOT NULL, "brand_name" text, "model" text, "model_code" text, "family_code" text, "model_year" text, "engine" text, "gearbox" text, "energy_type" text, "manufacturing_date" text, "catalog_vehicle_id" uuid, "raw" jsonb, "attempts" integer DEFAULT 0 NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone, "decoded_at" timestamp with time zone ); --> statement-breakpoint DO $$ BEGIN ALTER TABLE "rpartstore_decodes" ADD CONSTRAINT "rpartstore_decodes_catalog_vehicle_id_catalog_vehicles_id_fk" FOREIGN KEY ("catalog_vehicle_id") REFERENCES "public"."catalog_vehicles"("id") ON DELETE set null ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$; --> statement-breakpoint CREATE INDEX IF NOT EXISTS "rpartstore_decodes_status_idx" ON "rpartstore_decodes" USING btree ("status");