mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 15:46:41 +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
|
|
@ -10,7 +10,10 @@ export function loadConfig(): Config {
|
|||
const env = (key: string, fallback?: string) => process.env[key] || fallback || '';
|
||||
return {
|
||||
port: parseInt(env('PORT', '3062'), 10),
|
||||
databaseUrl: env('DATABASE_URL', 'postgresql://manacore:devpassword@localhost:5432/mana_user'),
|
||||
databaseUrl: env(
|
||||
'DATABASE_URL',
|
||||
'postgresql://manacore:devpassword@localhost:5432/mana_platform'
|
||||
),
|
||||
manaAuthUrl: env('MANA_CORE_AUTH_URL', 'http://localhost:3001'),
|
||||
serviceKey: env('MANA_CORE_SERVICE_KEY', 'dev-service-key'),
|
||||
cors: { origins: env('CORS_ORIGINS', 'http://localhost:5173').split(',') },
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
export * from './schema';
|
||||
export * from './tag-groups';
|
||||
export * from './tags';
|
||||
export * from './tag-links';
|
||||
|
|
|
|||
3
services/mana-user/src/db/schema/schema.ts
Normal file
3
services/mana-user/src/db/schema/schema.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { pgSchema } from 'drizzle-orm/pg-core';
|
||||
|
||||
export const usrSchema = pgSchema('usr');
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import { pgTable, text, jsonb, timestamp } from 'drizzle-orm/pg-core';
|
||||
import { text, jsonb, timestamp } from 'drizzle-orm/pg-core';
|
||||
import { usrSchema } from './schema';
|
||||
|
||||
export const userSettings = pgTable('user_settings', {
|
||||
export const userSettings = usrSchema.table('user_settings', {
|
||||
userId: text('user_id').primaryKey(),
|
||||
globalSettings: jsonb('global_settings')
|
||||
.default({
|
||||
|
|
|
|||
|
|
@ -1,15 +1,7 @@
|
|||
import {
|
||||
pgTable,
|
||||
varchar,
|
||||
text,
|
||||
uuid,
|
||||
timestamp,
|
||||
index,
|
||||
unique,
|
||||
integer,
|
||||
} from 'drizzle-orm/pg-core';
|
||||
import { varchar, text, uuid, timestamp, index, unique, integer } from 'drizzle-orm/pg-core';
|
||||
import { usrSchema } from './schema';
|
||||
|
||||
export const tagGroups = pgTable(
|
||||
export const tagGroups = usrSchema.table(
|
||||
'tag_groups',
|
||||
{
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { pgTable, varchar, text, uuid, timestamp, index, unique } from 'drizzle-orm/pg-core';
|
||||
import { varchar, text, uuid, timestamp, index, unique } from 'drizzle-orm/pg-core';
|
||||
import { usrSchema } from './schema';
|
||||
import { tags } from './tags';
|
||||
|
||||
export const tagLinks = pgTable(
|
||||
export const tagLinks = usrSchema.table(
|
||||
'tag_links',
|
||||
{
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
|
|||
|
|
@ -1,16 +1,8 @@
|
|||
import {
|
||||
pgTable,
|
||||
varchar,
|
||||
text,
|
||||
uuid,
|
||||
timestamp,
|
||||
index,
|
||||
unique,
|
||||
integer,
|
||||
} from 'drizzle-orm/pg-core';
|
||||
import { varchar, text, uuid, timestamp, index, unique, integer } from 'drizzle-orm/pg-core';
|
||||
import { usrSchema } from './schema';
|
||||
import { tagGroups } from './tag-groups';
|
||||
|
||||
export const tags = pgTable(
|
||||
export const tags = usrSchema.table(
|
||||
'tags',
|
||||
{
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue