managarten/services/mana-auth/sql
Till JS 698ffe797c feat(spaces): add spaces pg schema — credentials + module_permissions
Groundwork for server-side Space extensions that must NOT live in Dexie:
  - spaces.credentials         — per-space OAuth tokens, API keys, SMTP
                                 configs. Access tokens are stored
                                 encrypted at rest with the service KEK.
  - spaces.module_permissions  — role × module read/write/admin overrides
                                 on top of the SPACE_MODULE_ALLOWLIST
                                 defaults.

Both tables FK to auth.organizations with ON DELETE CASCADE so deleting
a space drops its credentials and permission overrides automatically.

RLS is intentionally deferred — enabling it now would lock out services
that don't yet pass space context. A follow-up migration turns it on
after mana-api speaks the Spaces protocol end-to-end.

To apply locally: bun run db:push in services/mana-auth, or psql -f
sql/004_spaces.sql against the mana_platform DB.

No runtime code reads these tables yet — they're the scaffolding that
Task-8 (mana-sync) and the eventual social-relay/clubs modules will
consume.

Plan: docs/plans/spaces-foundation.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 16:13:33 +02:00
..
001_add_access_tier.sql fix(inventar): import FeedbackPage from @manacore/feedback, not shared-ui 2026-03-30 21:56:19 +02:00
002_encryption_vaults.sql feat(mana-auth): encryption vault — phase 2 (server-side master key custody) 2026-04-07 18:38:09 +02:00
003_recovery_wrap.sql feat(mana-auth): phase 9 milestone 2 — vault recovery wrap + zero-knowledge 2026-04-07 22:05:49 +02:00
004_spaces.sql feat(spaces): add spaces pg schema — credentials + module_permissions 2026-04-20 16:13:33 +02:00