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

@ -3,9 +3,9 @@ import { defineConfig, type Config } from 'drizzle-kit';
export interface DrizzleConfigOptions {
/**
* Database name for fallback URL when DATABASE_URL is not set
* Example: 'calendar' -> postgresql://manacore:devpassword@localhost:5432/calendar
* @default 'mana_platform'
*/
dbName: string;
dbName?: string;
/**
* Path to schema file(s)
@ -82,7 +82,7 @@ const DEFAULT_PG_PASSWORD = 'devpassword';
*/
export function createDrizzleConfig(options: DrizzleConfigOptions): Config {
const {
dbName,
dbName = 'mana_platform',
schemaPath = './src/db/schema/index.ts',
outDir = './src/db/migrations',
envVar = 'DATABASE_URL',