56 lines
1.6 KiB
Bash
56 lines
1.6 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
# Quick test database setup script
|
||
|
|
# This script provides simple commands to set up the test database
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
echo "🔧 DBIS Core Lite - Quick Test Database Setup"
|
||
|
|
echo "=============================================="
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
DB_NAME="dbis_core_test"
|
||
|
|
DEFAULT_URL="postgresql://postgres:postgres@localhost:5432/${DB_NAME}"
|
||
|
|
|
||
|
|
# Function to check if command exists
|
||
|
|
command_exists() {
|
||
|
|
command -v "$1" >/dev/null 2>&1
|
||
|
|
}
|
||
|
|
|
||
|
|
# Check for PostgreSQL
|
||
|
|
if command_exists psql; then
|
||
|
|
echo "✅ PostgreSQL client found"
|
||
|
|
elif command_exists docker; then
|
||
|
|
echo "⚠️ PostgreSQL client not found, but Docker is available"
|
||
|
|
echo " You can use Docker to run PostgreSQL (see README_TEST_DATABASE.md)"
|
||
|
|
else
|
||
|
|
echo "❌ Neither PostgreSQL client nor Docker found"
|
||
|
|
echo " Please install PostgreSQL or Docker to continue"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "📋 Quick Setup Commands:"
|
||
|
|
echo ""
|
||
|
|
echo "1. Create test database:"
|
||
|
|
echo " createdb ${DB_NAME}"
|
||
|
|
echo ""
|
||
|
|
echo "2. Set environment variable:"
|
||
|
|
echo " export TEST_DATABASE_URL=\"${DEFAULT_URL}\""
|
||
|
|
echo " # Or create .env.test file (already created)"
|
||
|
|
echo ""
|
||
|
|
echo "3. Run migrations:"
|
||
|
|
echo " DATABASE_URL=\$TEST_DATABASE_URL npm run migrate"
|
||
|
|
echo ""
|
||
|
|
echo "4. Run tests:"
|
||
|
|
echo " npm test"
|
||
|
|
echo ""
|
||
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||
|
|
echo ""
|
||
|
|
echo "💡 Tip: Create .env.test file with:"
|
||
|
|
echo " TEST_DATABASE_URL=${DEFAULT_URL}"
|
||
|
|
echo ""
|
||
|
|
echo "📖 For detailed instructions, see: README_TEST_DATABASE.md"
|
||
|
|
echo ""
|
||
|
|
|