Something went wrong. Try again.
Your music, beautifully tracked. All yours. (coming soon) teal.fm
teal-fm atproto
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263#!/bin/bash
# Setup script for SQLx CLI and database migrations# This script installs sqlx-cli and sets up the database for development
set -e
echo "🔧 Setting up SQLx CLI and database..."
# Check if cargo is installedif ! command -v cargo &> /dev/null; then echo "❌ Cargo is not installed. Please install Rust first." exit 1fi
# Install sqlx-cli if not already installedif ! command -v sqlx &> /dev/null; then echo "📦 Installing sqlx-cli..." cargo install sqlx-cli --features postgreselse echo "✅ sqlx-cli is already installed"fi
# Check if DATABASE_URL is setif [ -z "$DATABASE_URL" ]; then echo "⚠️ DATABASE_URL not set. Using default: postgres://localhost/teal" export DATABASE_URL="postgres://localhost/teal"fi
echo "🗄️ Database URL: $DATABASE_URL"
# Navigate to services directory for sqlx commandscd services
# Check if database exists, create if it doesn'techo "🏗️ Creating database if it doesn't exist..."sqlx database create 2>/dev/null || echo "Database already exists or created successfully"
# Run migrationsecho "🚀 Running database migrations..."sqlx migrate run
# Prepare queries for compile-time verificationecho "🔍 Preparing queries for compile-time verification..."sqlx prepare --check 2>/dev/null || { echo "📝 Generating query metadata..." sqlx prepare}
cd ..
echo "✅ SQLx setup complete!"echo ""echo "Available commands:"echo " pnpm db:migrate - Run migrations"echo " pnpm db:migrate:revert - Revert last migration"echo " pnpm db:create - Create database"echo " pnpm db:drop - Drop database"echo " pnpm db:reset - Drop, create, and migrate database"echo " pnpm db:prepare - Prepare queries for compile-time verification"echo ""echo "🎉 Your database is ready for development!"