Your music, beautifully tracked. All yours. (coming soon)
teal.fm
teal-fm
atproto
1#!/bin/bash
2
3# Script to copy .sqlx files to all Rust projects that use SQLx
4# This is needed for offline SQLx builds (SQLX_OFFLINE=true)
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
15# List of projects that use SQLx (relative to project root)
16SQLX_PROJECTS=(
17 "apps/aqua"
18 "services/cadet"
19 "services/satellite"
20)
21
22echo "🔧 Setting up SQLx offline files..."
23
24# Check if source .sqlx directory exists
25if [ ! -d "$SQLX_SOURCE" ]; then
26 echo "❌ Source .sqlx directory not found at: $SQLX_SOURCE"
27 echo " Make sure you've run 'cargo sqlx prepare' from the services directory first."
28 exit 1
29fi
30
31# Copy .sqlx files to each project that needs them
32for project in "${SQLX_PROJECTS[@]}"; do
33 project_path="$PROJECT_ROOT/$project"
34 target_sqlx="$project_path/.sqlx"
35
36 if [ ! -d "$project_path" ]; then
37 echo "⚠️ Project directory not found: $project_path (skipping)"
38 continue
39 fi
40
41 # Check if project actually uses SQLx
42 if [ ! -f "$project_path/Cargo.toml" ]; then
43 echo "⚠️ No Cargo.toml found in $project (skipping)"
44 continue
45 fi
46
47 if ! grep -q "sqlx" "$project_path/Cargo.toml"; then
48 echo "⚠️ Project $project doesn't appear to use SQLx (skipping)"
49 continue
50 fi
51
52 echo "📦 Copying .sqlx files to $project..."
53
54 # Remove existing .sqlx directory if it exists
55 if [ -d "$target_sqlx" ]; then
56 rm -rf "$target_sqlx"
57 fi
58
59 # Copy the .sqlx directory
60 cp -r "$SQLX_SOURCE" "$target_sqlx"
61
62 echo " ✅ Copied $(ls -1 "$target_sqlx" | wc -l) query files"
63done
64
65echo "✅ SQLx offline setup complete!"
66echo ""
67echo "Note: If you add new SQL queries or modify existing ones, you'll need to:"
68echo "1. Run 'cargo sqlx prepare' from the services directory"
69echo "2. Run this script again to update all project copies"