This directory contains scripts for setting up PostgreSQL database storage for AI Agents session management.
setup_local_postgres.sh- Local PostgreSQL setup scriptsetup_heroku_postgres.sh- Heroku PostgreSQL setup scriptverify_db_setup.py- Database verification scriptPOSTGRES_SETUP.md- Detailed setup documentationREADME.md- This file
# Set up local PostgreSQL database
./setup_local_postgres.sh# Set up Heroku PostgreSQL addon
./setup_heroku_postgres.sh- Database Name:
ai_agents_session_store - Username:
ai_agents_user - Password:
ai_agents_password - Host:
localhost - Port:
5432
- Addon Name:
ai-agents-session-store - Plan:
essential-0($5/month) - Database Name: Auto-generated by Heroku
Sets up PostgreSQL on your local machine:
- Checks if PostgreSQL is installed and running
- Creates database and user if they don't exist
- Updates
.envfile withSESSION_STORE_URI - Handles macOS Homebrew PostgreSQL setup
Usage:
# Basic setup
./setup_local_postgres.sh
# Custom configuration
DB_NAME=my_db DB_USER=my_user ./setup_local_postgres.shSets up PostgreSQL addon on Heroku:
- Creates Heroku PostgreSQL addon
- Sets
SESSION_STORE_URIenvironment variable - Handles addon creation and configuration
Usage:
# Basic setup
./setup_heroku_postgres.sh
# Custom app name
APP_NAME=my-app ./setup_heroku_postgres.shVerifies database setup and connectivity:
- Tests database connection
- Verifies user permissions
- Tests table creation capabilities
Usage:
# Verify local setup
SESSION_STORE_URI="postgresql://ai_agents_user:ai_agents_password@localhost:5432/ai_agents_session_store" python verify_db_setup.py
# Verify Heroku setup
heroku run python verify_db_setup.py --app ai-agents-alpha# macOS with Homebrew
brew services start postgresql
# Check status
brew services list | grep postgresql# Create default database for your user
createdb $(whoami)
# Or connect as postgres user
psql -U postgresThe scripts check for existing databases and users before creating them, so it's safe to run multiple times.
# Check Heroku CLI login
heroku auth:whoami
# Check app access
heroku apps:info --app ai-agents-alpha# Check SESSION_STORE_URI
heroku config:get SESSION_STORE_URI --app ai-agents-alpha
# Set manually if needed
heroku config:set SESSION_STORE_URI="your-connection-string" --app ai-agents-alpha-- List all tables
\dt
-- Or using SQL
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';-- View sessions table
SELECT * FROM sessions LIMIT 10;
-- Check recent sessions
SELECT * FROM sessions ORDER BY create_time DESC LIMIT 5;-- Local PostgreSQL
SELECT pg_size_pretty(pg_database_size('ai_agents_session_store'));
-- Heroku PostgreSQL
SELECT pg_size_pretty(pg_database_size(current_database()));SESSION_STORE_URI- PostgreSQL connection string
DB_NAME- Database name (default: ai_agents_session_store)DB_USER- Database username (default: ai_agents_user)DB_PASSWORD- Database password (default: ai_agents_password)DB_HOST- Database host (default: localhost)DB_PORT- Database port (default: 5432)
APP_NAME- Heroku app name (default: ai-agents-alpha)POSTGRES_PLAN- PostgreSQL plan (default: essential-0)
# Check PostgreSQL status
brew services list | grep postgresql
# View PostgreSQL logs
tail -f /usr/local/var/log/postgres.log# Check addon status
heroku addons:info heroku-postgresql --app ai-agents-alpha
# View database metrics
heroku pg:info --app ai-agents-alpha- Main README - High-level architecture
- Installation Guide - Local setup guide
- Heroku Deployment - Production deployment
- Postman Collection - API testing