Skip to Content
Living documentation — last reviewed 2026-05-28
FeaturesExports ImportsExports & Imports — Data Model

Exports & Imports — Data Model

export_jobs (libs/db/src/lib/schema/exports.ts)

ColumnTypeNotes
iduuid PKJob identity.
organization_iduuid FKScope.
typevarcharcsv_members today; expandable.
statusenumpendingin_progresscompleted / failed.
configjsonbExportMembersDto.
started_byuuid FK → users.idRequester (for email + audit).
started_at, completed_at, updated_at, created_attimestampsLifecycle.
file_keyvarchar nullableR2 key on success (exports/<orgId>/<jobId>.csv).
resultsjsonb nullable{ rowCount, fileSize } on success.
error_messagetext nullablePopulated on failure.

import_jobs (libs/db/src/lib/schema/imports.ts)

ColumnTypeNotes
iduuid PKJob identity.
organization_iduuid FKScope.
sourceenumarbox or csv.
statusenumpendingin_progresscompleted / failed / cancelled.
phasevarcharFree-form phase label (plans, members, enrichment, done).
configjsonbSource-specific. Arbox: ImportConfigDto. CSV: { parsedRows, headers, suggestedMapping, columnMapping?, entities?, memberFields?, planFields? }.
started_byuuid FKRequester.
started_at, completed_at, updated_at, created_attimestampsLifecycle.
resultsjsonbPer-entity { created, skipped, failed, errors[] }.
error_messagetext nullableOrchestration-level failure.

import_provider_configs (libs/db/src/lib/schema/imports.ts)

ColumnTypeNotes
iduuid PKRow identity.
organization_iduuid FKScope.
providerenumarbox.
credentials_encryptedtextEncrypted JSON { apiKey, email?, password? }.
is_activebooleanOnly one active row per (org, provider).
created_at, updated_attimestampsAudit.

Encryption uses CredentialEncryptionService (shared with payment providers). FIT-120: rotating CREDENTIAL_ENCRYPTION_KEY makes old rows unreadable — re-enter credentials after rotation.

Tables written by imports

TableWrite
usersINSERT (new emails) or UPDATE (existing emails — merge non-null source fields).
membershipsINSERT a member role row in active status (or per arboxStatus).
member_profilesINSERT/UPDATE — full profile mirror including arbox_user_id for back-reference.
plansINSERT new plans by name + price; updates existing on name collision.
leads (when entity targeted)INSERT lead rows from CSV.

R2

  • exports/<orgId>/<jobId>.csv — UTF-8 with BOM.

Email

  • Sent from notifications/email.service.ts using the export-ready.ts template with a 1h presigned download URL.

Queues

QueueJob dataProducerConsumer
export{ jobId, orgId }ExportService.enqueueExportExportProcessor
import{ jobId, orgId }ImportService.{enqueueImport, confirmCsvImport}ImportProcessor
import-memberImportMemberJobDataImportService.fanOutMemberJobsImportMemberProcessor
import-enrichEnrichMemberJobDataImportService enrichment phaseImportEnrichProcessor
member-profiles-enrichment{ memberProfileId }ImportService (downstream)embeddings worker