-- Brainstorm Canvas v3.0 — Index composites
-- À appliquer manuellement si prisma migrate dev échoue sur la shadow DB

-- BrainstormParticipant: accélère verifyParticipant (lookup critique temps réel)
CREATE INDEX CONCURRENTLY IF NOT EXISTS "BrainstormParticipant_sessionId_userId_role_idx"
  ON "BrainstormParticipant" ("sessionId", "userId", "role");

-- BrainstormIdea: filtrage canvas par statut actif
CREATE INDEX CONCURRENTLY IF NOT EXISTS "BrainstormIdea_sessionId_status_idx"
  ON "BrainstormIdea" ("sessionId", "status");

-- BrainstormIdea: rendu ordonné du canvas (wave + date)
CREATE INDEX CONCURRENTLY IF NOT EXISTS "BrainstormIdea_sessionId_waveNumber_createdAt_idx"
  ON "BrainstormIdea" ("sessionId", "waveNumber", "createdAt");

-- BrainstormActivity: feed d'activité croissant
CREATE INDEX CONCURRENTLY IF NOT EXISTS "BrainstormActivity_sessionId_createdAt_asc_idx"
  ON "BrainstormActivity" ("sessionId", "createdAt" ASC);

-- BrainstormActivity: feed d'activité décroissant (pagination)
CREATE INDEX CONCURRENTLY IF NOT EXISTS "BrainstormActivity_sessionId_createdAt_desc_idx"
  ON "BrainstormActivity" ("sessionId", "createdAt" DESC);
