managarten/docker/init-db/02-create-schemas.sh
Till JS 3ea28b9065 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>
2026-04-02 14:31:28 +02:00

27 lines
913 B
Bash
Executable file

#!/bin/bash
# Create schemas within mana_platform database
# Docker entrypoint runs .sh files after .sql files
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname mana_platform <<-EOSQL
-- Core service schemas
CREATE SCHEMA IF NOT EXISTS auth;
CREATE SCHEMA IF NOT EXISTS credits;
CREATE SCHEMA IF NOT EXISTS gifts;
CREATE SCHEMA IF NOT EXISTS subscriptions;
CREATE SCHEMA IF NOT EXISTS feedback;
CREATE SCHEMA IF NOT EXISTS usr;
CREATE SCHEMA IF NOT EXISTS media;
-- App server-side schemas
CREATE SCHEMA IF NOT EXISTS todo;
CREATE SCHEMA IF NOT EXISTS traces;
CREATE SCHEMA IF NOT EXISTS presi;
CREATE SCHEMA IF NOT EXISTS uload;
CREATE SCHEMA IF NOT EXISTS cards;
-- Grant schema usage
GRANT ALL ON SCHEMA auth, credits, gifts, subscriptions, feedback, usr, media,
todo, traces, presi, uload, cards TO manacore;
EOSQL