Compare commits

..

1 Commits

Author SHA1 Message Date
7712286e1a infra: migrate postgres to shared openbrain_brain-db instance
Remove the dedicated stack-postgres service and postgres_data volume.
Instead join the openbrain_brain-internal overlay network and connect
to openbrain_brain-db for all database operations.

- Add mosaic-db-init service to provision mosaic user/db in openbrain's postgres
- Update synapse-db-init to use BRAIN_DB_ADMIN_* credentials and openbrain_brain-db host
- Update api DATABASE_URL to openbrain_brain-db:5432
- Add openbrain-brain-internal as external network

Required new Portainer env vars:
  BRAIN_DB_ADMIN_USER (default: openbrain)
  BRAIN_DB_ADMIN_PASSWORD (openbrain stack's POSTGRES_PASSWORD)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 21:45:01 -06:00
2 changed files with 0 additions and 17 deletions

View File

@@ -1,13 +0,0 @@
-- MS21: Add admin, local auth, and invitation fields to users table
-- These columns were added to schema.prisma but never captured in a migration.
ALTER TABLE "users"
ADD COLUMN IF NOT EXISTS "deactivated_at" TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS "is_local_auth" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN IF NOT EXISTS "password_hash" TEXT,
ADD COLUMN IF NOT EXISTS "invited_by" UUID,
ADD COLUMN IF NOT EXISTS "invitation_token" TEXT,
ADD COLUMN IF NOT EXISTS "invited_at" TIMESTAMPTZ;
-- CreateIndex
CREATE UNIQUE INDEX IF NOT EXISTS "users_invitation_token_key" ON "users"("invitation_token");

View File

@@ -91,10 +91,6 @@ services:
psql -h openbrain_brain-db -U $${PGUSER} -tc "SELECT 1 FROM pg_database WHERE datname='$${MOSAIC_DB}'" | grep -q 1 || \
psql -h openbrain_brain-db -U $${PGUSER} -c "CREATE DATABASE $${MOSAIC_DB} OWNER $${MOSAIC_USER} ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' TEMPLATE template0;"
echo "Enabling required extensions in $${MOSAIC_DB}..."
psql -h openbrain_brain-db -U $${PGUSER} -d $${MOSAIC_DB} -c "CREATE EXTENSION IF NOT EXISTS vector;"
psql -h openbrain_brain-db -U $${PGUSER} -d $${MOSAIC_DB} -c "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";"
echo "Mosaic database ready: $${MOSAIC_DB}"
networks:
- openbrain-brain-internal