#!/bin/bash

# Detect local container
LOCAL_CONTAINER=$(docker compose ps -q directus)

if [ -z "$LOCAL_CONTAINER" ]; then
    echo "❌ Local directus container not found. Is it running?"
    exit 1
fi

echo "📸 Creating schema snapshot..."
# Note: we save it to the mounted volume path inside the container
docker exec "$LOCAL_CONTAINER" npx directus schema snapshot /directus/schema/snapshot.yaml

echo "✅ Snapshot saved to ./directus/schema/snapshot.yaml"
