Data Access and Migrations
Persistence belongs behind application services that understand the current tenant or workspace, authorization context, and record lifecycle.
Query Safety
Use parameterized database operations, select only required fields, and apply scope conditions to every workspace-owned operation. Never treat a browser-provided identifier as proof of access.
Migration Discipline
Each schema change should be reviewed, ordered, repeatable, and paired with a deployment decision. Before promotion:
1. Confirm the change against the supported database versions. 2. Estimate locking and data-backfill impact. 3. Take a consistent backup when rollback depends on data restoration. 4. Apply in a representative environment. 5. Verify both the schema and the affected user workflow.
Do not rewrite a migration that has already been applied. Add a new migration that moves the schema forward.