Files
aura-crm/production/backend/migrations/053_external_components.sql
T

27 lines
1.1 KiB
SQL

-- +goose Up
-- external_components caches scraped catalog listings from supplier sites
-- (Regard, and later pg.pro/technosuccess.ru/DNS-shop) so the PC configurator
-- can offer just-in-time-sourced parts alongside the shop's own parts stock,
-- without hitting the supplier site on every picker render. Refreshed
-- periodically by internal/scraper, not written by any other code path.
CREATE TABLE external_components (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
source TEXT NOT NULL,
external_id TEXT NOT NULL,
pc_component_type TEXT NOT NULL CHECK (pc_component_type IN
('cpu', 'motherboard', 'ram', 'gpu', 'psu', 'case', 'cooler', 'storage')),
name TEXT NOT NULL,
price NUMERIC(12,2) NOT NULL,
product_url TEXT NOT NULL,
in_stock BOOLEAN NOT NULL DEFAULT true,
spec JSONB NOT NULL DEFAULT '{}'::jsonb,
scraped_at TIMESTAMPTZ NOT NULL DEFAULT now(),
UNIQUE (source, external_id)
);
CREATE INDEX idx_external_components_type ON external_components (pc_component_type);
-- +goose Down
DROP TABLE external_components;