diff --git a/drizzle/0000_adorable_shiver_man.sql b/drizzle/0000_adorable_shiver_man.sql new file mode 100644 index 0000000..0ddc7ae --- /dev/null +++ b/drizzle/0000_adorable_shiver_man.sql @@ -0,0 +1,269 @@ +CREATE TYPE "public"."analysis_decision" AS ENUM('FBA', 'FBM', 'BUY', 'WATCH', 'SKIP');--> statement-breakpoint +CREATE TYPE "public"."analysis_method" AS ENUM('llm', 'supplier_scoring');--> statement-breakpoint +CREATE TYPE "public"."run_status" AS ENUM('running', 'ok', 'empty', 'failed', 'completed');--> statement-breakpoint +CREATE TYPE "public"."run_type" AS ENUM('lead_analysis', 'category_analysis', 'supplier_upc', 'stalker', 'stalker_analysis');--> statement-breakpoint +CREATE TABLE "analysis_revisions" ( + "id" serial PRIMARY KEY NOT NULL, + "run_item_id" integer NOT NULL, + "observation_id" integer, + "method" "analysis_method" NOT NULL, + "decision" "analysis_decision" NOT NULL, + "confidence" real, + "reasoning" text, + "analyzed_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "analysis_run_stats" ( + "run_id" integer PRIMARY KEY NOT NULL, + "processed_count" integer DEFAULT 0 NOT NULL, + "analyzed_count" integer DEFAULT 0 NOT NULL, + "available_count" integer DEFAULT 0 NOT NULL, + "fba_count" integer DEFAULT 0 NOT NULL, + "fbm_count" integer DEFAULT 0 NOT NULL, + "buy_count" integer DEFAULT 0 NOT NULL, + "watch_count" integer DEFAULT 0 NOT NULL, + "skip_count" integer DEFAULT 0 NOT NULL +); +--> statement-breakpoint +CREATE TABLE "category_run_details" ( + "run_id" integer PRIMARY KEY NOT NULL, + "category_id" integer NOT NULL, + "category_label" text NOT NULL, + "checked_asin_count" integer DEFAULT 0 NOT NULL, + "selection_parameters_json" text +); +--> statement-breakpoint +CREATE TABLE "product_identifiers" ( + "id" serial PRIMARY KEY NOT NULL, + "product_asin" text NOT NULL, + "identifier_type" text NOT NULL, + "identifier_value" text NOT NULL, + "source" text NOT NULL, + "confirmed_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "uq_product_identifier_type_value" UNIQUE("identifier_type","identifier_value") +); +--> statement-breakpoint +CREATE TABLE "product_observations" ( + "id" serial PRIMARY KEY NOT NULL, + "product_asin" text NOT NULL, + "run_id" integer NOT NULL, + "source" text NOT NULL, + "marketplace" text DEFAULT 'US' NOT NULL, + "current_price" real, + "avg_price_90d" real, + "sales_rank" integer, + "sales_rank_avg_90d" integer, + "monthly_sold" integer, + "rank_drops_30d" integer, + "rank_drops_90d" integer, + "seller_count" integer, + "amazon_is_seller" boolean, + "amazon_buybox_share_pct_90d" real, + "fba_fee" real, + "fbm_fee" real, + "referral_percent" real, + "can_sell" boolean, + "sellability_status" text, + "sellability_reason" text, + "raw_product_json" text, + "fetched_at" timestamp with time zone NOT NULL +); +--> statement-breakpoint +CREATE TABLE "products" ( + "asin" text PRIMARY KEY NOT NULL, + "name" text, + "brand" text, + "category" text, + "metadata_fetched_at" timestamp with time zone, + "first_seen_at" timestamp with time zone DEFAULT now() NOT NULL, + "last_seen_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "ck_products_asin" CHECK ("products"."asin" ~ '^[A-Z0-9]{10}$') +); +--> statement-breakpoint +CREATE TABLE "run_items" ( + "id" serial PRIMARY KEY NOT NULL, + "run_id" integer NOT NULL, + "product_asin" text, + "source_inventory_item_id" integer, + "ordinal" integer, + "source_row" integer, + "status" text DEFAULT 'completed' NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "runs" ( + "id" serial PRIMARY KEY NOT NULL, + "type" "run_type" NOT NULL, + "parent_run_id" integer, + "input_file" text, + "output_file" text, + "status" "run_status" DEFAULT 'running' NOT NULL, + "error_message" text, + "started_at" timestamp with time zone DEFAULT now() NOT NULL, + "completed_at" timestamp with time zone +); +--> statement-breakpoint +CREATE TABLE "sellers" ( + "seller_id" text PRIMARY KEY NOT NULL, + "seller_name" text, + "rating" real, + "rating_count" integer, + "storefront_asin_total" integer, + "persisted_inventory_sample_count" integer, + "last_updated_at" timestamp with time zone NOT NULL, + "raw_seller_json" text +); +--> statement-breakpoint +CREATE TABLE "sourcing_inputs" ( + "run_item_id" integer PRIMARY KEY NOT NULL, + "supplied_name" text, + "supplied_brand" text, + "supplied_category" text, + "unit_cost" real, + "avg_price_90d_sheet" real, + "selling_price_sheet" real, + "fba_net_sheet" real, + "gross_profit_dollar" real, + "gross_profit_pct" real, + "net_profit_sheet" real, + "roi_sheet" real, + "moq" integer, + "moq_cost" real, + "qty_available" integer, + "supplier" text, + "source_url" text, + "asin_link" text, + "promo_coupon_code" text, + "notes" text, + "lead_date" text +); +--> statement-breakpoint +CREATE TABLE "stalker_inventory_items" ( + "id" serial PRIMARY KEY NOT NULL, + "run_id" integer NOT NULL, + "seller_id" text NOT NULL, + "product_asin" text NOT NULL, + "observation_id" integer NOT NULL, + "last_seen_at" timestamp with time zone NOT NULL, + "raw_inventory_json" text, + CONSTRAINT "uq_stalker_inventory_items_run_seller_asin" UNIQUE("run_id","seller_id","product_asin") +); +--> statement-breakpoint +CREATE TABLE "stalker_run_details" ( + "run_id" integer PRIMARY KEY NOT NULL, + "requested_asins" integer DEFAULT 0 NOT NULL, + "skipped_asins" integer DEFAULT 0 NOT NULL, + "scanned_asins" integer DEFAULT 0 NOT NULL, + "source_asins_with_matches" integer DEFAULT 0 NOT NULL, + "candidate_sellers" integer DEFAULT 0 NOT NULL, + "qualifying_sellers" integer DEFAULT 0 NOT NULL, + "matched_sellers" integer DEFAULT 0 NOT NULL, + "seller_metadata_requests" integer DEFAULT 0 NOT NULL, + "seller_storefront_requests" integer DEFAULT 0 NOT NULL, + "inventory_sellability_checked_asins" integer DEFAULT 0 NOT NULL, + "inventory_sellability_available_asins" integer DEFAULT 0 NOT NULL, + "inventory_sellability_excluded_asins" integer DEFAULT 0 NOT NULL, + "persisted_inventory_asins" integer DEFAULT 0 NOT NULL +); +--> statement-breakpoint +CREATE TABLE "stalker_scan_sellers" ( + "id" serial PRIMARY KEY NOT NULL, + "scan_id" integer NOT NULL, + "seller_id" text NOT NULL, + "offer_price" real, + "condition" text, + "is_fba" boolean, + "stock" integer, + "seller_rating" real, + "seller_rating_count" integer, + "raw_offer_json" text, + CONSTRAINT "uq_stalker_scan_sellers_scan_seller" UNIQUE("scan_id","seller_id") +); +--> statement-breakpoint +CREATE TABLE "stalker_scans" ( + "id" serial PRIMARY KEY NOT NULL, + "run_id" integer NOT NULL, + "source_product_asin" text NOT NULL, + "observation_id" integer, + "offer_count" integer DEFAULT 0 NOT NULL, + "candidate_seller_count" integer DEFAULT 0 NOT NULL, + "matched_seller_count" integer DEFAULT 0 NOT NULL, + "fetched_at" timestamp with time zone NOT NULL, + CONSTRAINT "uq_stalker_scans_run_source_product" UNIQUE("run_id","source_product_asin") +); +--> statement-breakpoint +CREATE TABLE "supplier_scores" ( + "revision_id" integer PRIMARY KEY NOT NULL, + "score" real, + "sale_price" real, + "fba_fee" real, + "profit" real, + "margin" real, + "roi" real, + "reason" text +); +--> statement-breakpoint +CREATE TABLE "upc_resolution_candidates" ( + "run_item_id" integer NOT NULL, + "product_asin" text NOT NULL, + CONSTRAINT "upc_resolution_candidates_run_item_id_product_asin_pk" PRIMARY KEY("run_item_id","product_asin") +); +--> statement-breakpoint +CREATE TABLE "upc_resolutions" ( + "run_item_id" integer PRIMARY KEY NOT NULL, + "requested_upc" text NOT NULL, + "normalized_upc" text NOT NULL, + "provider" text NOT NULL, + "status" text NOT NULL, + "reason" text, + "resolved_product_asin" text, + "resolved_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "analysis_revisions" ADD CONSTRAINT "analysis_revisions_run_item_id_run_items_id_fk" FOREIGN KEY ("run_item_id") REFERENCES "public"."run_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "analysis_revisions" ADD CONSTRAINT "analysis_revisions_observation_id_product_observations_id_fk" FOREIGN KEY ("observation_id") REFERENCES "public"."product_observations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "analysis_run_stats" ADD CONSTRAINT "analysis_run_stats_run_id_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "category_run_details" ADD CONSTRAINT "category_run_details_run_id_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "product_identifiers" ADD CONSTRAINT "product_identifiers_product_asin_products_asin_fk" FOREIGN KEY ("product_asin") REFERENCES "public"."products"("asin") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "product_observations" ADD CONSTRAINT "product_observations_product_asin_products_asin_fk" FOREIGN KEY ("product_asin") REFERENCES "public"."products"("asin") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "product_observations" ADD CONSTRAINT "product_observations_run_id_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "run_items" ADD CONSTRAINT "run_items_run_id_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "run_items" ADD CONSTRAINT "run_items_product_asin_products_asin_fk" FOREIGN KEY ("product_asin") REFERENCES "public"."products"("asin") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "run_items" ADD CONSTRAINT "run_items_source_inventory_item_id_stalker_inventory_items_id_fk" FOREIGN KEY ("source_inventory_item_id") REFERENCES "public"."stalker_inventory_items"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "runs" ADD CONSTRAINT "runs_parent_run_id_runs_id_fk" FOREIGN KEY ("parent_run_id") REFERENCES "public"."runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "sourcing_inputs" ADD CONSTRAINT "sourcing_inputs_run_item_id_run_items_id_fk" FOREIGN KEY ("run_item_id") REFERENCES "public"."run_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_inventory_items" ADD CONSTRAINT "stalker_inventory_items_run_id_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_inventory_items" ADD CONSTRAINT "stalker_inventory_items_seller_id_sellers_seller_id_fk" FOREIGN KEY ("seller_id") REFERENCES "public"."sellers"("seller_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_inventory_items" ADD CONSTRAINT "stalker_inventory_items_product_asin_products_asin_fk" FOREIGN KEY ("product_asin") REFERENCES "public"."products"("asin") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_inventory_items" ADD CONSTRAINT "stalker_inventory_items_observation_id_product_observations_id_fk" FOREIGN KEY ("observation_id") REFERENCES "public"."product_observations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_run_details" ADD CONSTRAINT "stalker_run_details_run_id_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_scan_sellers" ADD CONSTRAINT "stalker_scan_sellers_scan_id_stalker_scans_id_fk" FOREIGN KEY ("scan_id") REFERENCES "public"."stalker_scans"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_scan_sellers" ADD CONSTRAINT "stalker_scan_sellers_seller_id_sellers_seller_id_fk" FOREIGN KEY ("seller_id") REFERENCES "public"."sellers"("seller_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_scans" ADD CONSTRAINT "stalker_scans_run_id_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_scans" ADD CONSTRAINT "stalker_scans_source_product_asin_products_asin_fk" FOREIGN KEY ("source_product_asin") REFERENCES "public"."products"("asin") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "stalker_scans" ADD CONSTRAINT "stalker_scans_observation_id_product_observations_id_fk" FOREIGN KEY ("observation_id") REFERENCES "public"."product_observations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "supplier_scores" ADD CONSTRAINT "supplier_scores_revision_id_analysis_revisions_id_fk" FOREIGN KEY ("revision_id") REFERENCES "public"."analysis_revisions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "upc_resolution_candidates" ADD CONSTRAINT "upc_resolution_candidates_run_item_id_upc_resolutions_run_item_id_fk" FOREIGN KEY ("run_item_id") REFERENCES "public"."upc_resolutions"("run_item_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "upc_resolution_candidates" ADD CONSTRAINT "upc_resolution_candidates_product_asin_products_asin_fk" FOREIGN KEY ("product_asin") REFERENCES "public"."products"("asin") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "upc_resolutions" ADD CONSTRAINT "upc_resolutions_run_item_id_run_items_id_fk" FOREIGN KEY ("run_item_id") REFERENCES "public"."run_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "upc_resolutions" ADD CONSTRAINT "upc_resolutions_resolved_product_asin_products_asin_fk" FOREIGN KEY ("resolved_product_asin") REFERENCES "public"."products"("asin") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "idx_analysis_revisions_run_item_time" ON "analysis_revisions" USING btree ("run_item_id","analyzed_at");--> statement-breakpoint +CREATE INDEX "idx_analysis_revisions_decision" ON "analysis_revisions" USING btree ("decision");--> statement-breakpoint +CREATE INDEX "idx_product_identifiers_asin" ON "product_identifiers" USING btree ("product_asin");--> statement-breakpoint +CREATE INDEX "idx_product_observations_product_time" ON "product_observations" USING btree ("product_asin","fetched_at" DESC NULLS LAST);--> statement-breakpoint +CREATE INDEX "idx_product_observations_run_id" ON "product_observations" USING btree ("run_id");--> statement-breakpoint +CREATE INDEX "idx_product_observations_sellability" ON "product_observations" USING btree ("sellability_status");--> statement-breakpoint +CREATE INDEX "idx_products_name" ON "products" USING btree ("name");--> statement-breakpoint +CREATE INDEX "idx_products_last_seen_at" ON "products" USING btree ("last_seen_at");--> statement-breakpoint +CREATE INDEX "idx_run_items_run_id" ON "run_items" USING btree ("run_id");--> statement-breakpoint +CREATE INDEX "idx_run_items_product_asin" ON "run_items" USING btree ("product_asin");--> statement-breakpoint +CREATE INDEX "idx_runs_started_at" ON "runs" USING btree ("started_at");--> statement-breakpoint +CREATE INDEX "idx_runs_type" ON "runs" USING btree ("type");--> statement-breakpoint +CREATE INDEX "idx_runs_status" ON "runs" USING btree ("status");--> statement-breakpoint +CREATE INDEX "idx_runs_parent_run_id" ON "runs" USING btree ("parent_run_id");--> statement-breakpoint +CREATE INDEX "idx_stalker_inventory_seller_id" ON "stalker_inventory_items" USING btree ("seller_id");--> statement-breakpoint +CREATE INDEX "idx_stalker_inventory_product_asin" ON "stalker_inventory_items" USING btree ("product_asin");--> statement-breakpoint +CREATE INDEX "idx_stalker_scans_run_id" ON "stalker_scans" USING btree ("run_id");--> statement-breakpoint +CREATE INDEX "idx_stalker_scans_source_asin" ON "stalker_scans" USING btree ("source_product_asin");--> statement-breakpoint +CREATE INDEX "idx_upc_candidates_product_asin" ON "upc_resolution_candidates" USING btree ("product_asin");--> statement-breakpoint +CREATE INDEX "idx_upc_resolutions_normalized_upc" ON "upc_resolutions" USING btree ("normalized_upc"); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..4088654 --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,2025 @@ +{ + "id": "f3a73b1a-820c-4905-b998-55a9b70bc49d", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.analysis_revisions": { + "name": "analysis_revisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "run_item_id": { + "name": "run_item_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "observation_id": { + "name": "observation_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "method": { + "name": "method", + "type": "analysis_method", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "decision": { + "name": "decision", + "type": "analysis_decision", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "confidence": { + "name": "confidence", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "analyzed_at": { + "name": "analyzed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_analysis_revisions_run_item_time": { + "name": "idx_analysis_revisions_run_item_time", + "columns": [ + { + "expression": "run_item_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "analyzed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_analysis_revisions_decision": { + "name": "idx_analysis_revisions_decision", + "columns": [ + { + "expression": "decision", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "analysis_revisions_run_item_id_run_items_id_fk": { + "name": "analysis_revisions_run_item_id_run_items_id_fk", + "tableFrom": "analysis_revisions", + "tableTo": "run_items", + "columnsFrom": [ + "run_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analysis_revisions_observation_id_product_observations_id_fk": { + "name": "analysis_revisions_observation_id_product_observations_id_fk", + "tableFrom": "analysis_revisions", + "tableTo": "product_observations", + "columnsFrom": [ + "observation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.analysis_run_stats": { + "name": "analysis_run_stats", + "schema": "", + "columns": { + "run_id": { + "name": "run_id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "processed_count": { + "name": "processed_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "analyzed_count": { + "name": "analyzed_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "available_count": { + "name": "available_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "fba_count": { + "name": "fba_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "fbm_count": { + "name": "fbm_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "buy_count": { + "name": "buy_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "watch_count": { + "name": "watch_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skip_count": { + "name": "skip_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "analysis_run_stats_run_id_runs_id_fk": { + "name": "analysis_run_stats_run_id_runs_id_fk", + "tableFrom": "analysis_run_stats", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.category_run_details": { + "name": "category_run_details", + "schema": "", + "columns": { + "run_id": { + "name": "run_id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "category_id": { + "name": "category_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "category_label": { + "name": "category_label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "checked_asin_count": { + "name": "checked_asin_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "selection_parameters_json": { + "name": "selection_parameters_json", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "category_run_details_run_id_runs_id_fk": { + "name": "category_run_details_run_id_runs_id_fk", + "tableFrom": "category_run_details", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.product_identifiers": { + "name": "product_identifiers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "product_asin": { + "name": "product_asin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "identifier_type": { + "name": "identifier_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "identifier_value": { + "name": "identifier_value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_product_identifiers_asin": { + "name": "idx_product_identifiers_asin", + "columns": [ + { + "expression": "product_asin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "product_identifiers_product_asin_products_asin_fk": { + "name": "product_identifiers_product_asin_products_asin_fk", + "tableFrom": "product_identifiers", + "tableTo": "products", + "columnsFrom": [ + "product_asin" + ], + "columnsTo": [ + "asin" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_product_identifier_type_value": { + "name": "uq_product_identifier_type_value", + "nullsNotDistinct": false, + "columns": [ + "identifier_type", + "identifier_value" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.product_observations": { + "name": "product_observations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "product_asin": { + "name": "product_asin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "marketplace": { + "name": "marketplace", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'US'" + }, + "current_price": { + "name": "current_price", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "avg_price_90d": { + "name": "avg_price_90d", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "sales_rank": { + "name": "sales_rank", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "sales_rank_avg_90d": { + "name": "sales_rank_avg_90d", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "monthly_sold": { + "name": "monthly_sold", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "rank_drops_30d": { + "name": "rank_drops_30d", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "rank_drops_90d": { + "name": "rank_drops_90d", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "seller_count": { + "name": "seller_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "amazon_is_seller": { + "name": "amazon_is_seller", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "amazon_buybox_share_pct_90d": { + "name": "amazon_buybox_share_pct_90d", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "fba_fee": { + "name": "fba_fee", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "fbm_fee": { + "name": "fbm_fee", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "referral_percent": { + "name": "referral_percent", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "can_sell": { + "name": "can_sell", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "sellability_status": { + "name": "sellability_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sellability_reason": { + "name": "sellability_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "raw_product_json": { + "name": "raw_product_json", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_product_observations_product_time": { + "name": "idx_product_observations_product_time", + "columns": [ + { + "expression": "product_asin", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "fetched_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_product_observations_run_id": { + "name": "idx_product_observations_run_id", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_product_observations_sellability": { + "name": "idx_product_observations_sellability", + "columns": [ + { + "expression": "sellability_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "product_observations_product_asin_products_asin_fk": { + "name": "product_observations_product_asin_products_asin_fk", + "tableFrom": "product_observations", + "tableTo": "products", + "columnsFrom": [ + "product_asin" + ], + "columnsTo": [ + "asin" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "product_observations_run_id_runs_id_fk": { + "name": "product_observations_run_id_runs_id_fk", + "tableFrom": "product_observations", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "asin": { + "name": "asin", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "brand": { + "name": "brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata_fetched_at": { + "name": "metadata_fetched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_products_name": { + "name": "idx_products_name", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_products_last_seen_at": { + "name": "idx_products_last_seen_at", + "columns": [ + { + "expression": "last_seen_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "ck_products_asin": { + "name": "ck_products_asin", + "value": "\"products\".\"asin\" ~ '^[A-Z0-9]{10}$'" + } + }, + "isRLSEnabled": false + }, + "public.run_items": { + "name": "run_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_asin": { + "name": "product_asin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_inventory_item_id": { + "name": "source_inventory_item_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "ordinal": { + "name": "ordinal", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "source_row": { + "name": "source_row", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'completed'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_run_items_run_id": { + "name": "idx_run_items_run_id", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_run_items_product_asin": { + "name": "idx_run_items_product_asin", + "columns": [ + { + "expression": "product_asin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "run_items_run_id_runs_id_fk": { + "name": "run_items_run_id_runs_id_fk", + "tableFrom": "run_items", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "run_items_product_asin_products_asin_fk": { + "name": "run_items_product_asin_products_asin_fk", + "tableFrom": "run_items", + "tableTo": "products", + "columnsFrom": [ + "product_asin" + ], + "columnsTo": [ + "asin" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "run_items_source_inventory_item_id_stalker_inventory_items_id_fk": { + "name": "run_items_source_inventory_item_id_stalker_inventory_items_id_fk", + "tableFrom": "run_items", + "tableTo": "stalker_inventory_items", + "columnsFrom": [ + "source_inventory_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.runs": { + "name": "runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "run_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "parent_run_id": { + "name": "parent_run_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "input_file": { + "name": "input_file", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output_file": { + "name": "output_file", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_runs_started_at": { + "name": "idx_runs_started_at", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_runs_type": { + "name": "idx_runs_type", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_runs_status": { + "name": "idx_runs_status", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_runs_parent_run_id": { + "name": "idx_runs_parent_run_id", + "columns": [ + { + "expression": "parent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "runs_parent_run_id_runs_id_fk": { + "name": "runs_parent_run_id_runs_id_fk", + "tableFrom": "runs", + "tableTo": "runs", + "columnsFrom": [ + "parent_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sellers": { + "name": "sellers", + "schema": "", + "columns": { + "seller_id": { + "name": "seller_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "seller_name": { + "name": "seller_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rating": { + "name": "rating", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "rating_count": { + "name": "rating_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "storefront_asin_total": { + "name": "storefront_asin_total", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "persisted_inventory_sample_count": { + "name": "persisted_inventory_sample_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_updated_at": { + "name": "last_updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "raw_seller_json": { + "name": "raw_seller_json", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sourcing_inputs": { + "name": "sourcing_inputs", + "schema": "", + "columns": { + "run_item_id": { + "name": "run_item_id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "supplied_name": { + "name": "supplied_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplied_brand": { + "name": "supplied_brand", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "supplied_category": { + "name": "supplied_category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unit_cost": { + "name": "unit_cost", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "avg_price_90d_sheet": { + "name": "avg_price_90d_sheet", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "selling_price_sheet": { + "name": "selling_price_sheet", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "fba_net_sheet": { + "name": "fba_net_sheet", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "gross_profit_dollar": { + "name": "gross_profit_dollar", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "gross_profit_pct": { + "name": "gross_profit_pct", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "net_profit_sheet": { + "name": "net_profit_sheet", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "roi_sheet": { + "name": "roi_sheet", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "moq": { + "name": "moq", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "moq_cost": { + "name": "moq_cost", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "qty_available": { + "name": "qty_available", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "supplier": { + "name": "supplier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "asin_link": { + "name": "asin_link", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "promo_coupon_code": { + "name": "promo_coupon_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lead_date": { + "name": "lead_date", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "sourcing_inputs_run_item_id_run_items_id_fk": { + "name": "sourcing_inputs_run_item_id_run_items_id_fk", + "tableFrom": "sourcing_inputs", + "tableTo": "run_items", + "columnsFrom": [ + "run_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.stalker_inventory_items": { + "name": "stalker_inventory_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "seller_id": { + "name": "seller_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "product_asin": { + "name": "product_asin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "observation_id": { + "name": "observation_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "raw_inventory_json": { + "name": "raw_inventory_json", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "idx_stalker_inventory_seller_id": { + "name": "idx_stalker_inventory_seller_id", + "columns": [ + { + "expression": "seller_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_stalker_inventory_product_asin": { + "name": "idx_stalker_inventory_product_asin", + "columns": [ + { + "expression": "product_asin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stalker_inventory_items_run_id_runs_id_fk": { + "name": "stalker_inventory_items_run_id_runs_id_fk", + "tableFrom": "stalker_inventory_items", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stalker_inventory_items_seller_id_sellers_seller_id_fk": { + "name": "stalker_inventory_items_seller_id_sellers_seller_id_fk", + "tableFrom": "stalker_inventory_items", + "tableTo": "sellers", + "columnsFrom": [ + "seller_id" + ], + "columnsTo": [ + "seller_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stalker_inventory_items_product_asin_products_asin_fk": { + "name": "stalker_inventory_items_product_asin_products_asin_fk", + "tableFrom": "stalker_inventory_items", + "tableTo": "products", + "columnsFrom": [ + "product_asin" + ], + "columnsTo": [ + "asin" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stalker_inventory_items_observation_id_product_observations_id_fk": { + "name": "stalker_inventory_items_observation_id_product_observations_id_fk", + "tableFrom": "stalker_inventory_items", + "tableTo": "product_observations", + "columnsFrom": [ + "observation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_stalker_inventory_items_run_seller_asin": { + "name": "uq_stalker_inventory_items_run_seller_asin", + "nullsNotDistinct": false, + "columns": [ + "run_id", + "seller_id", + "product_asin" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.stalker_run_details": { + "name": "stalker_run_details", + "schema": "", + "columns": { + "run_id": { + "name": "run_id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "requested_asins": { + "name": "requested_asins", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "skipped_asins": { + "name": "skipped_asins", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "scanned_asins": { + "name": "scanned_asins", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "source_asins_with_matches": { + "name": "source_asins_with_matches", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "candidate_sellers": { + "name": "candidate_sellers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "qualifying_sellers": { + "name": "qualifying_sellers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "matched_sellers": { + "name": "matched_sellers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "seller_metadata_requests": { + "name": "seller_metadata_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "seller_storefront_requests": { + "name": "seller_storefront_requests", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "inventory_sellability_checked_asins": { + "name": "inventory_sellability_checked_asins", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "inventory_sellability_available_asins": { + "name": "inventory_sellability_available_asins", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "inventory_sellability_excluded_asins": { + "name": "inventory_sellability_excluded_asins", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "persisted_inventory_asins": { + "name": "persisted_inventory_asins", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "stalker_run_details_run_id_runs_id_fk": { + "name": "stalker_run_details_run_id_runs_id_fk", + "tableFrom": "stalker_run_details", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.stalker_scan_sellers": { + "name": "stalker_scan_sellers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "scan_id": { + "name": "scan_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "seller_id": { + "name": "seller_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "offer_price": { + "name": "offer_price", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "condition": { + "name": "condition", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_fba": { + "name": "is_fba", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "seller_rating": { + "name": "seller_rating", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "seller_rating_count": { + "name": "seller_rating_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "raw_offer_json": { + "name": "raw_offer_json", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "stalker_scan_sellers_scan_id_stalker_scans_id_fk": { + "name": "stalker_scan_sellers_scan_id_stalker_scans_id_fk", + "tableFrom": "stalker_scan_sellers", + "tableTo": "stalker_scans", + "columnsFrom": [ + "scan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stalker_scan_sellers_seller_id_sellers_seller_id_fk": { + "name": "stalker_scan_sellers_seller_id_sellers_seller_id_fk", + "tableFrom": "stalker_scan_sellers", + "tableTo": "sellers", + "columnsFrom": [ + "seller_id" + ], + "columnsTo": [ + "seller_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_stalker_scan_sellers_scan_seller": { + "name": "uq_stalker_scan_sellers_scan_seller", + "nullsNotDistinct": false, + "columns": [ + "scan_id", + "seller_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.stalker_scans": { + "name": "stalker_scans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "source_product_asin": { + "name": "source_product_asin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "observation_id": { + "name": "observation_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "offer_count": { + "name": "offer_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "candidate_seller_count": { + "name": "candidate_seller_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "matched_seller_count": { + "name": "matched_seller_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "fetched_at": { + "name": "fetched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_stalker_scans_run_id": { + "name": "idx_stalker_scans_run_id", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_stalker_scans_source_asin": { + "name": "idx_stalker_scans_source_asin", + "columns": [ + { + "expression": "source_product_asin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "stalker_scans_run_id_runs_id_fk": { + "name": "stalker_scans_run_id_runs_id_fk", + "tableFrom": "stalker_scans", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "stalker_scans_source_product_asin_products_asin_fk": { + "name": "stalker_scans_source_product_asin_products_asin_fk", + "tableFrom": "stalker_scans", + "tableTo": "products", + "columnsFrom": [ + "source_product_asin" + ], + "columnsTo": [ + "asin" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "stalker_scans_observation_id_product_observations_id_fk": { + "name": "stalker_scans_observation_id_product_observations_id_fk", + "tableFrom": "stalker_scans", + "tableTo": "product_observations", + "columnsFrom": [ + "observation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "uq_stalker_scans_run_source_product": { + "name": "uq_stalker_scans_run_source_product", + "nullsNotDistinct": false, + "columns": [ + "run_id", + "source_product_asin" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.supplier_scores": { + "name": "supplier_scores", + "schema": "", + "columns": { + "revision_id": { + "name": "revision_id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "score": { + "name": "score", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "sale_price": { + "name": "sale_price", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "fba_fee": { + "name": "fba_fee", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "profit": { + "name": "profit", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "margin": { + "name": "margin", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "roi": { + "name": "roi", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "supplier_scores_revision_id_analysis_revisions_id_fk": { + "name": "supplier_scores_revision_id_analysis_revisions_id_fk", + "tableFrom": "supplier_scores", + "tableTo": "analysis_revisions", + "columnsFrom": [ + "revision_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.upc_resolution_candidates": { + "name": "upc_resolution_candidates", + "schema": "", + "columns": { + "run_item_id": { + "name": "run_item_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "product_asin": { + "name": "product_asin", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idx_upc_candidates_product_asin": { + "name": "idx_upc_candidates_product_asin", + "columns": [ + { + "expression": "product_asin", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "upc_resolution_candidates_run_item_id_upc_resolutions_run_item_id_fk": { + "name": "upc_resolution_candidates_run_item_id_upc_resolutions_run_item_id_fk", + "tableFrom": "upc_resolution_candidates", + "tableTo": "upc_resolutions", + "columnsFrom": [ + "run_item_id" + ], + "columnsTo": [ + "run_item_id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "upc_resolution_candidates_product_asin_products_asin_fk": { + "name": "upc_resolution_candidates_product_asin_products_asin_fk", + "tableFrom": "upc_resolution_candidates", + "tableTo": "products", + "columnsFrom": [ + "product_asin" + ], + "columnsTo": [ + "asin" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "upc_resolution_candidates_run_item_id_product_asin_pk": { + "name": "upc_resolution_candidates_run_item_id_product_asin_pk", + "columns": [ + "run_item_id", + "product_asin" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.upc_resolutions": { + "name": "upc_resolutions", + "schema": "", + "columns": { + "run_item_id": { + "name": "run_item_id", + "type": "integer", + "primaryKey": true, + "notNull": true + }, + "requested_upc": { + "name": "requested_upc", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "normalized_upc": { + "name": "normalized_upc", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_product_asin": { + "name": "resolved_product_asin", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idx_upc_resolutions_normalized_upc": { + "name": "idx_upc_resolutions_normalized_upc", + "columns": [ + { + "expression": "normalized_upc", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "upc_resolutions_run_item_id_run_items_id_fk": { + "name": "upc_resolutions_run_item_id_run_items_id_fk", + "tableFrom": "upc_resolutions", + "tableTo": "run_items", + "columnsFrom": [ + "run_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "upc_resolutions_resolved_product_asin_products_asin_fk": { + "name": "upc_resolutions_resolved_product_asin_products_asin_fk", + "tableFrom": "upc_resolutions", + "tableTo": "products", + "columnsFrom": [ + "resolved_product_asin" + ], + "columnsTo": [ + "asin" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.analysis_decision": { + "name": "analysis_decision", + "schema": "public", + "values": [ + "FBA", + "FBM", + "BUY", + "WATCH", + "SKIP" + ] + }, + "public.analysis_method": { + "name": "analysis_method", + "schema": "public", + "values": [ + "llm", + "supplier_scoring" + ] + }, + "public.run_status": { + "name": "run_status", + "schema": "public", + "values": [ + "running", + "ok", + "empty", + "failed", + "completed" + ] + }, + "public.run_type": { + "name": "run_type", + "schema": "public", + "values": [ + "lead_analysis", + "category_analysis", + "supplier_upc", + "stalker", + "stalker_analysis" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..96ebeac --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1779726518779, + "tag": "0000_adorable_shiver_man", + "breakpoints": true + } + ] +} \ No newline at end of file