37 lines
1.2 KiB
Bash
37 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
# Manual database initialization script
|
|
# Run this to initialize the TimescaleDB schema
|
|
|
|
echo "🔧 Initializing TimescaleDB schema..."
|
|
|
|
# Check if we can connect to the database
|
|
echo "📡 Testing connection to TimescaleDB..."
|
|
|
|
# You can run this command on your Docker host (192.168.0.10)
|
|
# Replace with your actual password from the .env file
|
|
|
|
PGPASSWORD="market_data_secure_pass_2024" psql -h 192.168.0.10 -p 5432 -U market_user -d market_data -c "SELECT version();"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Connection successful!"
|
|
|
|
echo "🏗️ Creating database schema..."
|
|
|
|
# Execute the initialization script
|
|
PGPASSWORD="market_data_secure_pass_2024" psql -h 192.168.0.10 -p 5432 -U market_user -d market_data -f ../docker/init-scripts/01-init-timescaledb.sql
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Database schema initialized successfully!"
|
|
|
|
echo "📊 Verifying tables..."
|
|
PGPASSWORD="market_data_secure_pass_2024" psql -h 192.168.0.10 -p 5432 -U market_user -d market_data -c "\dt market_data.*"
|
|
|
|
else
|
|
echo "❌ Schema initialization failed"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "❌ Cannot connect to database"
|
|
exit 1
|
|
fi |