Files
GearBox/drizzle-pg/0006_remarkable_susan_delgado.sql
Jean-Luc Makiola e10f0eda3d feat(33-02): generate migration for market_prices, community_prices tables
- CREATE TABLE market_prices with unique(global_item_id, market, currency)
- CREATE TABLE community_prices with unique(global_item_id, user_id, source_type)
- ALTER TABLE items ADD COLUMN price_currency
- ALTER TABLE thread_candidates ADD COLUMN found_price_cents, found_price_currency, found_price_date
- Note: db:push requires running PostgreSQL — apply on deployment

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 18:02:40 +02:00

31 lines
1.8 KiB
SQL

CREATE TABLE "community_prices" (
"id" serial PRIMARY KEY NOT NULL,
"global_item_id" integer NOT NULL,
"user_id" integer NOT NULL,
"market" text NOT NULL,
"currency" text NOT NULL,
"price_cents" integer NOT NULL,
"price_date" timestamp,
"source_type" text NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "community_prices_global_item_id_user_id_source_type_unique" UNIQUE("global_item_id","user_id","source_type")
);
--> statement-breakpoint
CREATE TABLE "market_prices" (
"id" serial PRIMARY KEY NOT NULL,
"global_item_id" integer NOT NULL,
"market" text NOT NULL,
"currency" text NOT NULL,
"price_cents" integer NOT NULL,
"source" text,
"created_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "market_prices_global_item_id_market_currency_unique" UNIQUE("global_item_id","market","currency")
);
--> statement-breakpoint
ALTER TABLE "items" ADD COLUMN "price_currency" text DEFAULT 'EUR';--> statement-breakpoint
ALTER TABLE "thread_candidates" ADD COLUMN "found_price_cents" integer;--> statement-breakpoint
ALTER TABLE "thread_candidates" ADD COLUMN "found_price_currency" text;--> statement-breakpoint
ALTER TABLE "thread_candidates" ADD COLUMN "found_price_date" timestamp;--> statement-breakpoint
ALTER TABLE "community_prices" ADD CONSTRAINT "community_prices_global_item_id_global_items_id_fk" FOREIGN KEY ("global_item_id") REFERENCES "public"."global_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "community_prices" ADD CONSTRAINT "community_prices_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "market_prices" ADD CONSTRAINT "market_prices_global_item_id_global_items_id_fk" FOREIGN KEY ("global_item_id") REFERENCES "public"."global_items"("id") ON DELETE cascade ON UPDATE no action;