Architecture

Data partitioning and retention

Partitioning organizes data into separate logical or physical groups. Tenant data may share tables, use separate schemas, or live in separate databases; each choice changes isolation and operational cost. Pooled tables simplify fleet migrations but share resources. Database-per-tenant can improve recovery granularity and reduce certain blast radii, while increasing connection, provisioning and update complexity. Define retention by data class, tenant agreement and legal hold; deletion from primary storage does not necessarily remove backups or audit records. Use bounded batches and verify each tenant scope. A retention date is a policy input, not a universal legal rule. Do not delete all old records without checking holds, ownership and recovery requirements. Sources: https://www.postgresql.org/docs/18/ddl-rowsecurity.html.

Formal Syntax & Structure

nodejs syntaxnodejs
Select eligible retention candidates (conceptual contract; see example)

Working Example

Example Snippetnodejs
import assert from 'node:assert/strict';const rows=[{id:'a',tenant:'t1',day:2,hold:false},{id:'b',tenant:'t1',day:1,hold:true},{id:'c',tenant:'t2',day:1,hold:false}];const eligible=rows.filter(r=>r.tenant==='t1'&&r.day<5&&!r.hold).map(r=>r.id);assert.deepEqual(eligible,['a']);console.log(eligible.join(','));
Node.js Reference