Your music, beautifully tracked. All yours. (coming soon) teal.fm
teal-fm atproto
Something went wrong. Try again.
Shell
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!"