1#!/bin/bash
2
3# Script to verify .sqlx files exist for offline SQLx builds (SQLX_OFFLINE=true)
4# With unified workspace, .sqlx only needs to exist at the project root
5
6set -e
7
8# Get the script directory (should be in teal/scripts/)
9SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
11
12# Source .sqlx directory
13SQLX_SOURCE="$PROJECT_ROOT/.sqlx"
14
15echo "🔧 Verifying SQLx offline files..."
16
17# Check if source .sqlx directory exists
18if [ ! -d "$SQLX_SOURCE" ]; then
19 echo "❌ .sqlx directory not found at: $SQLX_SOURCE"
20 echo " Make sure you've run 'cargo sqlx prepare' from the project root first."
21 exit 1
22fi
23
24query_count=$(ls -1 "$SQLX_SOURCE" | wc -l | tr -d ' ')
25echo "✅ Found .sqlx directory with $query_count query files"
26echo "✅ SQLx offline mode ready!"
27echo ""
28echo "Note: If you add new SQL queries or modify existing ones, run 'cargo sqlx prepare' from the project root"