feat: add missing migration 02 (images+pricing) and 03 (global keywords)

This commit is contained in:
2026-06-16 22:08:55 +02:00
parent 0b19c3d8f2
commit fcd192420f
2 changed files with 100 additions and 0 deletions
@@ -0,0 +1,26 @@
-- ============================================================
-- Migration 02 — image column on ads + price_history tracking
-- ============================================================
-- -----------------------------------------------------------
-- 1. Add main_image_url to ads (nullable)
-- -----------------------------------------------------------
ALTER TABLE ads
ADD COLUMN IF NOT EXISTS main_image_url TEXT;
-- -----------------------------------------------------------
-- 2. price_history — record every price change per ad
-- -----------------------------------------------------------
CREATE TABLE IF NOT EXISTS price_history (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
ad_id uuid NOT NULL REFERENCES ads(id) ON DELETE CASCADE,
old_price numeric NOT NULL,
new_price numeric NOT NULL,
changed_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (ad_id, old_price, new_price)
);
CREATE INDEX IF NOT EXISTS idx_price_history_ad_id
ON price_history(ad_id);
-- Note: supabase_admin role creation + grants moved to post-boot.sql.