#!/usr/bin/env bash
set -euo pipefail
echo "📦 Copie SQL…"
docker compose cp backend/sql/matches.sql db:/tmp/matches.sql
docker compose cp backend/sql/seed_matches.sql db:/tmp/seed_matches.sql || true

echo "🗃  Applique matches.sql…"
docker compose exec db sh -lc 'psql -U postgres -d supersunday -f /tmp/matches.sql'

echo "🌱 (Optionnel) seed demo…"
docker compose exec db sh -lc 'psql -U postgres -d supersunday -f /tmp/seed_matches.sql' || true

echo "✅ Terminé."
