mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:01:08 +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
|
|
@ -6,7 +6,7 @@
|
|||
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
import {
|
||||
pgTable,
|
||||
pgSchema,
|
||||
uuid,
|
||||
text,
|
||||
boolean,
|
||||
|
|
@ -18,7 +18,7 @@ import {
|
|||
import { relations } from 'drizzle-orm';
|
||||
|
||||
const DATABASE_URL =
|
||||
process.env.DATABASE_URL ?? 'postgresql://manacore:devpassword@localhost:5432/presi';
|
||||
process.env.DATABASE_URL ?? 'postgresql://manacore:devpassword@localhost:5432/mana_platform';
|
||||
|
||||
const connection = postgres(DATABASE_URL, {
|
||||
max: 5,
|
||||
|
|
@ -27,7 +27,9 @@ const connection = postgres(DATABASE_URL, {
|
|||
|
||||
// ─── Schema (read-only for share lookups) ────────────────
|
||||
|
||||
export const decks = pgTable('decks', {
|
||||
export const presiSchema = pgSchema('presi');
|
||||
|
||||
export const decks = presiSchema.table('decks', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
userId: text('user_id').notNull(),
|
||||
title: text('title').notNull(),
|
||||
|
|
@ -38,7 +40,7 @@ export const decks = pgTable('decks', {
|
|||
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export const slides = pgTable(
|
||||
export const slides = presiSchema.table(
|
||||
'slides',
|
||||
{
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
@ -50,7 +52,7 @@ export const slides = pgTable(
|
|||
(table) => [index('slides_deck_order_idx').on(table.deckId, table.order)]
|
||||
);
|
||||
|
||||
export const themes = pgTable('themes', {
|
||||
export const themes = presiSchema.table('themes', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
name: text('name').notNull(),
|
||||
colors: jsonb('colors'),
|
||||
|
|
@ -58,7 +60,7 @@ export const themes = pgTable('themes', {
|
|||
isDefault: boolean('is_default').default(false),
|
||||
});
|
||||
|
||||
export const sharedDecks = pgTable(
|
||||
export const sharedDecks = presiSchema.table(
|
||||
'shared_decks',
|
||||
{
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue