mem0 / init-db.sh
keithproject's picture
mem0 self-hosted: full deployment (auth fix, nginx routing, 9router LLM config)
5ec8557
Raw
History Blame Contribute Delete
888 Bytes
#!/bin/bash
set -e
echo "[init-db] Initializing mem0 database..."
# Wait for PostgreSQL to be ready
until pg_isready -q -h localhost -p 5432 -U mem0; do
echo "[init-db] Waiting for PostgreSQL..."
sleep 2
done
echo "[init-db] PostgreSQL is ready"
# Create database and user if they don't exist
psql -h localhost -p 5432 -U mem0 -d postgres <<-EOSQL
-- Create mem0 database
SELECT 'CREATE DATABASE mem0' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'mem0')\gexec
-- Create mem0_app database for auth/config
SELECT 'CREATE DATABASE mem0_app' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'mem0_app')\gexec
-- Enable pgvector extension on both databases
\c mem0
CREATE EXTENSION IF NOT EXISTS vector;
\c mem0_app
CREATE EXTENSION IF NOT EXISTS vector;
EOSQL
echo "[init-db] Database initialization complete"