Quality / test (push) Canceled after 0s
Add seller-owned pricing observation persistence, median market valuation calculation, admin routes, contracts, validation, migration, and focused tests.
30 lines
1.3 KiB
SQL
30 lines
1.3 KiB
SQL
CREATE TABLE "pricing_observations" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"product_id" uuid NOT NULL REFERENCES "products"("id"),
|
|
"inventory_item_id" uuid NOT NULL REFERENCES "inventory_items"("id"),
|
|
"provider_id" text NOT NULL,
|
|
"price_minor" integer NOT NULL,
|
|
"currency" text NOT NULL,
|
|
"source_identifier" text NOT NULL,
|
|
"condition_id" uuid NOT NULL REFERENCES "conditions"("id"),
|
|
"source_url" text,
|
|
"quality_score" integer,
|
|
"is_outlier" boolean DEFAULT false NOT NULL,
|
|
"outlier_reason" text,
|
|
"observed_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX "pricing_observations_inventory_item_id_index" ON "pricing_observations" USING btree ("inventory_item_id");
|
|
--> statement-breakpoint
|
|
CREATE TABLE "market_valuations" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"inventory_item_id" uuid NOT NULL REFERENCES "inventory_items"("id"),
|
|
"value_minor" integer NOT NULL,
|
|
"currency" text NOT NULL,
|
|
"strategy" text NOT NULL,
|
|
"confidence" text NOT NULL,
|
|
"source_count" integer NOT NULL,
|
|
"calculated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
); |