Habify BaseHabify Base
DB Isolation & PDPLHabify Base · Data Systems Engineering2026-11-16 (updated 2026-11-28)7 min read

Why Every BaaS Project Needs a Dedicated Physical PostgreSQL Database

How physical per-project PostgreSQL 18 databases prevent cross-tenant leaks, simplify Law 91/2025 compliance, and unlock lossless .hpb portability.

PostgreSQL 18Default-Deny RLSLaw 91/2025Portable .hpb

Shared multi-tenant databases leave every application exposed to a single missing WHERE clause or misconfigured policy. Under strict privacy regulations such as Vietnam's Personal Data Protection Law 91/2025/QH15, logical separation alone creates unnecessary blast radius.

Habify Base provisions an isolated physical PostgreSQL 18 database (hb_proj_<ulid>) per project, paired with a dedicated operational role (hb_role_<ulid>) and an isolated Data API execution role (hb_rls_<ulid> marked NOLOGIN, NOINHERIT, with zero CONNECT privilege).

Even anonymous browser requests carrying only hb_pk_* must execute inside a transaction running SET LOCAL ROLE hb_rls_<ulid> with app.current_role = 'anon'. Any public table missing ENABLE + FORCE ROW LEVEL SECURITY or lacking at least one policy fails closed immediately.

Blast-Radius Comparison: Shared Schema vs. Isolated Physical Database

Beyond security boundaries, shared schemas create noisy-neighbor outages whenever one tenant runs unindexed queries or floods connection pools.

Habify Base isolates every project through dedicated PgBouncer pools and 5 Fair-Use layers (connection limit, work_mem, statement_timeout, max_tables, and 5-minute quota monitoring).

CriterionShared DB / tenant_idHabify Base (Isolated PG18 DB)
Blast radius on missing WHERECross-tenant exposureStrictly scoped per DB and blocked by Default-Deny FORCE RLS
Noisy-neighbor protectionShared lock & pool contentionTiered connection/work_mem/timeout limits per project
Migration & PortabilityComplex row-level dump scriptsClean per-role pg_dump into lossless .hpb bundle

Standard FORCE ROW LEVEL SECURITY SQL Pattern

Whether authoring SQL manually or via our /skill.md AI integration, enable both statements below on every public table:

sql
ALTER TABLE public.customer_leads ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.customer_leads FORCE ROW LEVEL SECURITY;

CREATE POLICY "leads_owner_only" ON public.customer_leads
  USING (owner_id = current_setting('app.current_user_id', true))
  WITH CHECK (owner_id = current_setting('app.current_user_id', true));

Frequently Asked Questions

Are PostgreSQL storage and MAU pooled across Projects?

Yes. All Workspace quotas (MAU, PostgreSQL DB GB, R2 Storage, Egress, and API Requests) are pooled across the Workspace so growing projects never hit artificial silos.

Related Documentation & Guides

Launch This Architecture in Free Sandbox in 3 Minutes

Spin up an isolated PostgreSQL 18 database, grab your hb_pk_* / hb_sk_* keys, and wire @habifybase/sdk.

More Engineering Articles & Use Cases