90ac0b81d1
Add full V2 architecture: identity, content, studio (.NET 10) and file, render, notification, gateway (Go) services with vendored deps, plus DB migrations, event/API contracts, and an init-db script. Wire the Next.js frontend to the gateway: server-side JWT auth routes (login/register/refresh/logout/me), gateway fetch helper, and session/ cookie/jwt helpers under src/lib. Containerize the stack via docker-compose.v2.yml and per-service Dockerfiles. Base images resolve through a Nexus mirror (Docker Hub) and MCR directly; npm/NuGet pull from Nexus groups. Self-host fonts via next/font/local to avoid Google Fonts (geo-blocked). Add CI workflow and ignore .env.v2, *.stackdump, and .NET bin/obj. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
52 lines
2.3 KiB
PL/PgSQL
52 lines
2.3 KiB
PL/PgSQL
-- =====================================================================
|
|
-- FlatRender V2 — Database Setup
|
|
-- Single PostgreSQL database with per-service schemas
|
|
-- =====================================================================
|
|
|
|
-- Extensions
|
|
CREATE EXTENSION IF NOT EXISTS "pgcrypto"; -- gen_random_uuid()
|
|
CREATE EXTENSION IF NOT EXISTS "citext"; -- case-insensitive text (emails)
|
|
CREATE EXTENSION IF NOT EXISTS "pg_trgm"; -- fuzzy text search
|
|
|
|
-- =====================================================================
|
|
-- Schemas (one per microservice)
|
|
-- =====================================================================
|
|
CREATE SCHEMA IF NOT EXISTS identity;
|
|
CREATE SCHEMA IF NOT EXISTS content;
|
|
CREATE SCHEMA IF NOT EXISTS studio;
|
|
CREATE SCHEMA IF NOT EXISTS render;
|
|
CREATE SCHEMA IF NOT EXISTS file_mgr;
|
|
CREATE SCHEMA IF NOT EXISTS notification;
|
|
|
|
-- =====================================================================
|
|
-- Service users (each microservice connects with limited grants)
|
|
-- =====================================================================
|
|
-- Run separately by ops:
|
|
-- CREATE USER svc_identity WITH PASSWORD '...';
|
|
-- CREATE USER svc_content WITH PASSWORD '...';
|
|
-- CREATE USER svc_studio WITH PASSWORD '...';
|
|
-- CREATE USER svc_render WITH PASSWORD '...';
|
|
-- CREATE USER svc_file WITH PASSWORD '...';
|
|
-- CREATE USER svc_notification WITH PASSWORD '...';
|
|
-- GRANT ALL ON SCHEMA identity TO svc_identity;
|
|
-- GRANT ALL ON SCHEMA content TO svc_content;
|
|
-- ... etc.
|
|
-- Read-only cross-schema grants where needed (defined per service)
|
|
|
|
-- =====================================================================
|
|
-- Common helper: auto-update updated_at on row update
|
|
-- =====================================================================
|
|
CREATE OR REPLACE FUNCTION public.tg_set_updated_at()
|
|
RETURNS TRIGGER AS $$
|
|
BEGIN
|
|
NEW.updated_at = NOW();
|
|
RETURN NEW;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
-- =====================================================================
|
|
-- Common helper: soft-delete check (used in policies/views later)
|
|
-- =====================================================================
|
|
-- Convention: every soft-deletable table has `deleted_at TIMESTAMPTZ NULL`
|
|
-- Active rows: WHERE deleted_at IS NULL
|