Skip to main content
Docs/Database (Advanced)
DocsDatabase (Advanced)
Free

Database (Advanced)

Migrations, column-naming contract, the back-compat alias map, and where row-level security stands. Sibling to /docs/database for power users.

Migrations

When you change a schema after the table has been provisioned, GenMB applies the diff: new columns added with their defaults, removed columns dropped, type changes applied where Postgres permits. The migration runs on save; the Database Browser reflects the new state immediately.

Type changes are best-effort. Dropping a column is permanent. For destructive changes on a live app with real data, back up via Export first or use a transient workspace to validate.

Column Naming

Every Postgres column is quoted camelCase. The provisioner enforces this for both your declared columns and the auto-injected createdAt / updatedAt stamps it adds when you do not declare them yourself.

When writing handlers or queries, refer to columns by their camelCase name in quotes ("createdAt") to match what is actually in the database.

Back-Compat Aliases

For tables provisioned before 2026-05 (when the camelCase contract landed), and for any caller still emitting snake_case names, an alias map is applied in the DataConnect read path: created_atcreatedAt, updated_atupdatedAt. The alias is suppressed when the user's schema declares the snake_case name itself.

When adding new SDK endpoints or handler queries that interpolate a column name into SQL (GROUP BY / DISTINCT / JOIN / search), use the platform's safe-identifier guard and alias-map lookup so legacy snake_case continues to resolve.

Row-Level Security

A Postgres RLS DDL builder ships in the platform but is not on by default. Until it is feature-flagged on, you enforce per-row access in handler code: read the signed-in user from window.genmb.auth and gate on row.userId === user.id or via your RBAC role.

Stuck Schemas

If a schema lands in pending or failed, the DataConnect router auto-recovers on the first SDK request in production by re-running provisioning. Local dev does not auto-recover; use the Cloud SQL Auth Proxy snippet in the backend CLAUDE.md to re-provision manually.

See Database & Schema for the basic workflow.

FAQs

When do I need this page vs /docs/database?
Most users only need /docs/database (schema designer, browser, basic CRUD). Read this page when you are doing schema migrations on a live app, debugging a column-naming mismatch, or planning for row-level security.
Can I run raw SQL?
Through the Database Browser, yes (read queries). Production writes happen through the DataConnect SDK with parameterized queries; arbitrary SQL writes are intentionally not exposed to avoid bypassing the safety nets.
What is the column-naming contract?
Every Postgres column is quoted camelCase, including the auto-injected createdAt and updatedAt timestamps. A back-compat alias map (created_at -> createdAt, updated_at -> updatedAt) keeps callers that still emit snake_case working.
Is row-level security (RLS) available?
The RLS DDL builder exists (services/data_rls.py) but is not auto-enabled today. Until it is feature-flagged on, enforce per-row access in your handler code by checking the signed-in user against the row userId.

Ready to build?

Create your first app for free, no credit card required.