From 6fbcf907408a34649c1808b5d9c39ed41ddb210d Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 18 May 2026 08:31:11 -0700 Subject: [PATCH] feat(db): Postgres schema for shared sellers, market_comps, reported_sellers --- app/db/pg_migrations/001_shared_tables.sql | 43 ++++++++++++++++++++++ app/db/pg_migrations/__init__.py | 0 2 files changed, 43 insertions(+) create mode 100644 app/db/pg_migrations/001_shared_tables.sql create mode 100644 app/db/pg_migrations/__init__.py diff --git a/app/db/pg_migrations/001_shared_tables.sql b/app/db/pg_migrations/001_shared_tables.sql new file mode 100644 index 0000000..d78631d --- /dev/null +++ b/app/db/pg_migrations/001_shared_tables.sql @@ -0,0 +1,43 @@ +-- Snipe shared tables: sellers, market_comps, reported_sellers +-- Replaces the equivalent tables in shared.db (SQLite). +-- Per-user tables (listings, trust_scores, saved_searches) remain in SQLite. + +CREATE TABLE IF NOT EXISTS sellers ( + id BIGSERIAL PRIMARY KEY, + platform TEXT NOT NULL, + platform_seller_id TEXT NOT NULL, + username TEXT NOT NULL, + account_age_days INTEGER, + feedback_count INTEGER NOT NULL DEFAULT 0, + feedback_ratio DOUBLE PRECISION NOT NULL DEFAULT 0, + category_history_json TEXT NOT NULL DEFAULT '{}', + fetched_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE (platform, platform_seller_id) +); + +CREATE TABLE IF NOT EXISTS market_comps ( + id BIGSERIAL PRIMARY KEY, + platform TEXT NOT NULL, + query_hash TEXT NOT NULL, + median_price DOUBLE PRECISION NOT NULL, + sample_count INTEGER NOT NULL, + fetched_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + expires_at TIMESTAMPTZ NOT NULL, + UNIQUE (platform, query_hash) +); + +CREATE TABLE IF NOT EXISTS reported_sellers ( + id BIGSERIAL PRIMARY KEY, + platform TEXT NOT NULL, + platform_seller_id TEXT NOT NULL, + username TEXT, + reported_by TEXT NOT NULL DEFAULT 'user', + reported_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE (platform, platform_seller_id) +); + +-- Migration tracking (same pattern as CommunityDB in circuitforge-core) +CREATE TABLE IF NOT EXISTS _snipe_shared_migrations ( + filename TEXT PRIMARY KEY, + applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); diff --git a/app/db/pg_migrations/__init__.py b/app/db/pg_migrations/__init__.py new file mode 100644 index 0000000..e69de29