refactor(db): consolidate ~20+ databases into 2 (mana_platform + mana_sync)

Mirrors the frontend unification (single IndexedDB) on the backend.
All services now use pgSchema() for isolation within one shared database,
enabling cross-schema JOINs, simplified ops, and zero DB setup for new apps.

- Migrate 7 services from pgTable() to pgSchema(): mana-user (usr),
  mana-media (media), todo, traces, presi, uload, cards
- Update all DATABASE_URLs in .env.development, docker-compose, configs
- Rewrite init-db scripts for 2 databases + 12 schemas
- Rewrite setup-databases.sh for consolidated architecture
- Update shared-drizzle-config default to mana_platform
- Update CLAUDE.md with new database architecture docs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-02 14:31:28 +02:00
parent b1a5c95f1d
commit 3ea28b9065
44 changed files with 311 additions and 346 deletions

View file

@ -58,7 +58,7 @@ S3_SECRET_KEY=minioadmin
# ============================================
MANA_CORE_AUTH_PORT=3001
MANA_CORE_AUTH_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/manacore
MANA_CORE_AUTH_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
JWT_ACCESS_TOKEN_EXPIRY=15m
JWT_REFRESH_TOKEN_EXPIRY=7d
JWT_ISSUER=manacore
@ -155,7 +155,7 @@ UMAMI_WEBSITE_ID_MUKKE_LANDING=b2c9ab34-3c53-4463-9dde-1ecf098886a5
# Chat Backend
CHAT_BACKEND_PORT=3002
CHAT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/chat
CHAT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
DEV_BYPASS_AUTH=true
DEV_USER_ID=00000000-0000-0000-0000-000000000000
@ -187,7 +187,7 @@ MAERCHENZAUBER_REPLICATE_API_KEY=YOUR_KEY
# ============================================
CARDS_BACKEND_PORT=3009
CARDS_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/cards
CARDS_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
CARDS_APP_ID=cea4bfc6-a4de-4e17-91e2-54275940156e
# ============================================
@ -196,7 +196,7 @@ CARDS_APP_ID=cea4bfc6-a4de-4e17-91e2-54275940156e
PICTURE_BACKEND_PORT=3006
PICTURE_BACKEND_URL=http://localhost:3006
PICTURE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/picture
PICTURE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# Replicate API Token for AI image generation
PICTURE_REPLICATE_API_TOKEN=r8_QlvkstNhIc6NBX1ktpQ6ibvzOE2d2UQ1Emamd
@ -214,7 +214,7 @@ PICTURE_MANA_CORE_SERVICE_KEY=
# ============================================
NUTRIPHI_BACKEND_PORT=3023
NUTRIPHI_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/nutriphi
NUTRIPHI_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
NUTRIPHI_APP_ID=nutriphi
# Google Gemini API for food image analysis
@ -228,14 +228,14 @@ NUTRIPHI_S3_PUBLIC_URL=http://localhost:9000/nutriphi-storage
# ============================================
ZITARE_BACKEND_PORT=3007
ZITARE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/zitare
ZITARE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# ZITARE TELEGRAM BOT
# ============================================
ZITARE_BOT_PORT=3303
ZITARE_BOT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/zitare_bot
ZITARE_BOT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
ZITARE_BOT_TELEGRAM_TOKEN=8489424174:AAHHG_mlLVeu6xAWY6U2ZGXO0D8JKWnqBvg
# ============================================
@ -243,7 +243,7 @@ ZITARE_BOT_TELEGRAM_TOKEN=8489424174:AAHHG_mlLVeu6xAWY6U2ZGXO0D8JKWnqBvg
# ============================================
TODO_BOT_PORT=3304
TODO_BOT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/todo_bot
TODO_BOT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
TODO_BOT_TELEGRAM_TOKEN=8363906368:AAHzNC1DPSb0TUb2a3UGWWH1_rrAQFdBv2w
TODO_BOT_API_URL=http://localhost:3018
@ -252,14 +252,14 @@ TODO_BOT_API_URL=http://localhost:3018
# ============================================
PRESI_BACKEND_PORT=3008
PRESI_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/presi
PRESI_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# VOXEL-LAVA PROJECT
# ============================================
VOXEL_LAVA_BACKEND_PORT=3010
VOXEL_LAVA_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/voxel_lava
VOXEL_LAVA_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
VOXEL_LAVA_API_URL=http://localhost:3010
# ============================================
@ -267,7 +267,7 @@ VOXEL_LAVA_API_URL=http://localhost:3010
# ============================================
CONTACTS_BACKEND_PORT=3015
CONTACTS_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/contacts
CONTACTS_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# S3 Storage for contact photos
CONTACTS_S3_BUCKET=contacts-photos
@ -286,7 +286,7 @@ CONTACTS_GOOGLE_REDIRECT_URI=http://localhost:5184/import?tab=google
CALENDAR_BACKEND_PORT=3014
CALENDAR_BACKEND_URL=http://localhost:3014
CALENDAR_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/calendar
CALENDAR_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# Speech-to-Text Service (mana-stt)
# Production: https://stt-api.mana.how
@ -298,7 +298,7 @@ STT_URL=https://stt-api.mana.how
# ============================================
CONTEXT_BACKEND_PORT=3020
CONTEXT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/context
CONTEXT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# AI API Keys (server-side only)
CONTEXT_AZURE_OPENAI_API_KEY=YOUR_KEY
@ -310,7 +310,7 @@ CONTEXT_GOOGLE_API_KEY=YOUR_KEY
# ============================================
STORAGE_BACKEND_PORT=3016
STORAGE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/storage
STORAGE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
STORAGE_S3_PUBLIC_URL=http://localhost:9000/storage-storage
STORAGE_MAX_FILE_SIZE=104857600
STORAGE_MAX_FILES_PER_UPLOAD=10
@ -320,7 +320,7 @@ STORAGE_MAX_FILES_PER_UPLOAD=10
# ============================================
CLOCK_BACKEND_PORT=3017
CLOCK_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/clock
CLOCK_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# TODO PROJECT
@ -328,14 +328,14 @@ CLOCK_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/clock
TODO_BACKEND_PORT=3018
TODO_BACKEND_URL=http://localhost:3018
TODO_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/todo
TODO_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# MOODLIT PROJECT
# ============================================
MOODLIT_BACKEND_PORT=3012
MOODLIT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/moods
MOODLIT_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# MANA-GAMES PROJECT
@ -364,14 +364,14 @@ MANA_GAMES_GITHUB_REPO=mana-games
# ============================================
FINANCE_BACKEND_PORT=3019
FINANCE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/finance
FINANCE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# INVENTORY PROJECT
# ============================================
INVENTORY_BACKEND_PORT=3020
INVENTORY_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/inventory
INVENTORY_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
INVENTORY_S3_PUBLIC_URL=http://localhost:9000/inventory-storage
# ============================================
@ -379,14 +379,14 @@ INVENTORY_S3_PUBLIC_URL=http://localhost:9000/inventory-storage
# ============================================
TECHBASE_BACKEND_PORT=3021
TECHBASE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/techbase
TECHBASE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# PLANTA PROJECT
# ============================================
PLANTA_BACKEND_PORT=3022
PLANTA_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/planta
PLANTA_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
PLANTA_S3_PUBLIC_URL=http://localhost:9000/planta-storage
# Google Gemini API for plant vision analysis
@ -397,27 +397,27 @@ PLANTA_GEMINI_API_KEY=AIzaSyC_-hPWpVttTlqJdU4jbXR5H0OAnRi2LgI
# ============================================
TRACES_BACKEND_PORT=3026
TRACES_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/traces
TRACES_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# SKILLTREE PROJECT
# ============================================
SKILLTREE_BACKEND_PORT=3024
SKILLTREE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/skilltree
SKILLTREE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# MUKKE PROJECT
# ============================================
MUKKE_BACKEND_PORT=3010
MUKKE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mukke
MUKKE_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
# ============================================
# CITYCORNERS PROJECT
# ============================================
CITYCORNERS_BACKEND_PORT=3025
CITYCORNERS_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/citycorners
CITYCORNERS_DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_platform
CITYCORNERS_WEB_PORT=5196
# ============================================