Guides / Export customer data from PostgreSQL for the EU Data Act
Art. 25, Art. 26(b), Art. 29

Export customer data from PostgreSQL for the EU Data Act

Implement Chapter VI Regulation (EU) 2023/2854 tenant export and reverse-FK erasure in multi-tenant PostgreSQL without SQL injection or egress fees.

Key facts

RegulationRegulation (EU) 2023/2854 (Chapter VI)
Transition Period30 calendar days at most (Art. 25(2)(a)); up to 7 months if technically unfeasible and notified within 14 working days (Art. 25(4)); the customer may extend once (Art. 25(5))
Output FormatsRFC 4180 CSV, NDJSON, SHA-256 manifest.json
Switching ChargesCost-based only until January 12, 2027, none after, including switching-related egress (Art. 29)

Options compared

ApproachTenant IsolationFK Erasure OrderManifest Checksums
Ad-hoc pg_dumpManual WHERE filtering riskNot scoped per tenantNone
Parameterized Tenant QueriesStrict $1 tenant_id bindingReverse topological orderPer-file SHA-256

1. Enforce Parameterized Tenant Queries Across Every Table

Every exportable table in PostgreSQL must resolve back to a verified tenant isolation key such as organization_id or tenant_id. Never concatenate tenant identifiers into raw SQL strings.

Tables lacking a direct tenant_id column must join deterministically through their parent foreign key chain before writing rows to NDJSON or CSV.

Parameterized PostgreSQL tenant export (TypeScript)
export async function exportTenantTable(
  client: { query: (sql: string, params: unknown[]) => Promise<{ rows: Record<string, unknown>[] }> },
  table: string,
  tenantColumn: string,
  tenantId: string
): Promise<string> {
  const result = await client.query(
    `SELECT * FROM "${table}" WHERE "${tenantColumn}" = $1 ORDER BY 1`,
    [tenantId]
  );
  return result.rows.map((row) => JSON.stringify(row)).join("\n");
}

2. Execute Post-Retrieval Erasure in Reverse Foreign-Key Order

Article 25(2)(h) requires full erasure of exportable data and customer digital assets after the minimum 30-calendar-day retrieval window closes. Deleting parent rows before child rows triggers foreign-key constraint failures or leaves orphaned objects.

Always run a dry-run count first, delete child tables in reverse dependency order inside a transaction, and emit a structured row-count log for your Certificate of Erasure.

Reverse-FK erasure order SQL
BEGIN;
DELETE FROM invoice_items WHERE invoice_id IN (SELECT id FROM invoices WHERE tenant_id = $1);
DELETE FROM invoices WHERE tenant_id = $1;
DELETE FROM projects WHERE tenant_id = $1;
COMMIT;

Close the gaps

The kit gives you the public Art. 26 and Art. 28 pages, code to export a customer's data, and a tracker for switching deadlines.