Market Data Service is a high-performance financial data API that provides comprehensive Symbol prices of different markets through both RESTful endpoints and real-time WebSocket connections.

init-db.sh 871B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. set -e
  3. # Database initialization script for PostgreSQL
  4. # This script creates the database if it doesn't exist
  5. # This runs automatically when PostgreSQL container starts for the first time
  6. DB_NAME="${POSTGRES_DB:-financial_data}"
  7. DB_USER="${POSTGRES_USER:-postgres}"
  8. echo "Initializing database ${DB_NAME}..."
  9. # The database is already created by POSTGRES_DB environment variable
  10. # We just need to ensure it exists and set up permissions
  11. psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
  12. -- Grant all privileges to the postgres user
  13. GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} TO ${DB_USER};
  14. -- Connect to the database and set up schema
  15. \c ${DB_NAME}
  16. -- Create extensions if needed
  17. CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
  18. EOSQL
  19. echo "Database ${DB_NAME} initialized successfully."