Database Setup for AlphaPulse
This document explains how to set up the database for the AlphaPulse exchange synchronization module.
Prerequisites
- PostgreSQL installed and running
- PostgreSQL client tools (
psql
) available in your PATH
Automatic Setup
The easiest way to set up the database is to use the provided script:
# Make the script executable
chmod +x create_alphapulse_db.sh
# Run the script
./create_alphapulse_db.sh
This script will:
- Create a database user
testuser
with passwordtestpassword
if it doesn’t exist - Create a database named
alphapulse
owned bytestuser
if it doesn’t exist - Grant all privileges on the database to the user
Manual Setup
If you prefer to set up the database manually, follow these steps:
- Connect to PostgreSQL as a superuser:
psql -U postgres
- Create the database user:
CREATE USER testuser WITH PASSWORD 'testpassword';
- Create the database:
CREATE DATABASE alphapulse OWNER testuser;
- Grant privileges:
GRANT ALL PRIVILEGES ON DATABASE alphapulse TO testuser;
Configuration
The exchange sync module uses the following environment variables for database configuration:
export DB_USER="testuser"
export DB_PASS="testpassword"
export DB_HOST="localhost"
export DB_PORT="5432"
export DB_NAME="alphapulse"
You can modify these values in the test_exchange_sync.sh
script if needed.
Tables
The following tables will be automatically created when you run the exchange sync module:
portfolio_items
- Stores portfolio data for each exchange and assetsync_history
- Tracks synchronization operations
Troubleshooting
If you encounter database connection issues:
- Verify PostgreSQL is running:
pg_isready -h localhost -p 5432
- Check if the database exists:
psql -U postgres -c "SELECT datname FROM pg_database WHERE datname='alphapulse';"
- Verify the user has proper permissions:
psql -U postgres -c "SELECT rolname, rolsuper, rolcreaterole, rolcreatedb FROM pg_roles WHERE rolname='testuser';"
- Check PostgreSQL logs for any errors: ```bash tail -f /var/log/postgresql/postgresql-*.log