setup-test-db.sh
#!/bin/bash # PostgreSQL Test Database Setup Script # This script sets up the test database for integration tests set -e echo "Setting up PostgreSQL test database..." # Create test database and user if they don't exist sudo -u postgres psql -c "CREATE DATABASE jill_website_test;" 2>/dev/null || echo "Database already exists" sudo -u postgres psql -c "CREATE USER jill_test WITH PASSWORD 'test_password_123';" 2>/dev/null || echo "User already exists" sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE jill_website_test TO jill_test;" sudo -u postgres psql -d jill_website_test -c "GRANT ALL ON SCHEMA public TO jill_test;" sudo -u postgres psql -d jill_website_test -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO jill_test;" sudo -u postgres psql -d jill_website_test -c "GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO jill_test;" sudo -u postgres psql -d jill_website_test -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO jill_test;" sudo -u postgres psql -d jill_website_test -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO jill_test;" # Also create production database sudo -u postgres psql -c "CREATE DATABASE jill_website;" 2>/dev/null || echo "Production database already exists" sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE jill_website TO jill_test;" sudo -u postgres psql -d jill_website -c "GRANT ALL ON SCHEMA public TO jill_test;" echo "" echo "✅ Test database setup complete!" echo "Database: jill_website_test" echo "User: jill_test" echo "Password: test_password_123"