mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-26 10:14:37 +02:00
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:
parent
b1a5c95f1d
commit
3ea28b9065
44 changed files with 311 additions and 346 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import {
|
||||
pgTable,
|
||||
pgSchema,
|
||||
uuid,
|
||||
text,
|
||||
timestamp,
|
||||
|
|
@ -11,11 +11,13 @@ import {
|
|||
} from 'drizzle-orm/pg-core';
|
||||
import { relations } from 'drizzle-orm';
|
||||
|
||||
export const mediaSchema = pgSchema('media');
|
||||
|
||||
/**
|
||||
* Core media table - stores unique files by content hash (SHA-256)
|
||||
* This is the Content-Addressable Storage (CAS) approach
|
||||
*/
|
||||
export const media = pgTable(
|
||||
export const media = mediaSchema.table(
|
||||
'media',
|
||||
{
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
@ -70,7 +72,7 @@ export const media = pgTable(
|
|||
* Media references - tracks which user/app owns a reference to a media item
|
||||
* Multiple users can reference the same media (deduplication)
|
||||
*/
|
||||
export const mediaReferences = pgTable(
|
||||
export const mediaReferences = mediaSchema.table(
|
||||
'media_references',
|
||||
{
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
@ -101,7 +103,7 @@ export const mediaReferences = pgTable(
|
|||
* Lazy-generated thumbnails cache
|
||||
* Stores on-the-fly generated thumbnails with specific parameters
|
||||
*/
|
||||
export const mediaThumbnails = pgTable(
|
||||
export const mediaThumbnails = mediaSchema.table(
|
||||
'media_thumbnails',
|
||||
{
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue