-- Phase 8 forward-only query indexes.
-- Do not edit 20260725000000_add_phase8_intelligence: it may already be
-- applied in production. These indexes support Market Explorer, Store
-- Intelligence, Creator Intelligence, dashboard summaries, and scheduler
-- cleanup without changing data shape.

CREATE INDEX IF NOT EXISTS "products_storeId_isActive_idx" ON "products"("storeId", "isActive");
CREATE INDEX IF NOT EXISTS "products_sourceId_status_idx" ON "products"("sourceId", "status");
CREATE INDEX IF NOT EXISTS "products_isActive_isDeleted_lastSeenAt_idx" ON "products"("isActive", "isDeleted", "lastSeenAt");

CREATE INDEX IF NOT EXISTS "product_scores_demandAccelerationScore_idx" ON "product_scores"("demandAccelerationScore");
CREATE INDEX IF NOT EXISTS "product_scores_competitionTrendScore_idx" ON "product_scores"("competitionTrendScore");

CREATE INDEX IF NOT EXISTS "saved_products_productId_idx" ON "saved_products"("productId");

CREATE INDEX IF NOT EXISTS "search_history_query_idx" ON "search_history"("query");
CREATE INDEX IF NOT EXISTS "search_history_createdAt_idx" ON "search_history"("createdAt");

CREATE INDEX IF NOT EXISTS "creators_region_idx" ON "creators"("region");
CREATE INDEX IF NOT EXISTS "creators_followerCount_idx" ON "creators"("followerCount");
CREATE INDEX IF NOT EXISTS "creators_lastSeenAt_idx" ON "creators"("lastSeenAt");

CREATE INDEX IF NOT EXISTS "stores_region_idx" ON "stores"("region");
CREATE INDEX IF NOT EXISTS "stores_growthScore_idx" ON "stores"("growthScore");
CREATE INDEX IF NOT EXISTS "stores_productCount_idx" ON "stores"("productCount");
CREATE INDEX IF NOT EXISTS "stores_lastSeenAt_idx" ON "stores"("lastSeenAt");
