Skip to main content

Database

Sanvex core ships five migrations that create sv_* tables. With sanvex/core installed, run:

Tables

sv_accounts

Stores encrypted credentials per driver and owner. Unique constraint: (owner_type, owner_id, driver, key_name). This is where sanvex:setup writes tokens.

sv_entities

Cached or synced entities from external services. Unique constraint: (owner_type, owner_id, driver, entity_type, entity_id). Drivers expose local DB access via $driver->db() (e.g. db()->repositories()).

sv_events

Webhook and event log.

sv_permissions

Approval records for guarded actions. Approval URL is configured via SANVEX_APPROVAL_URL (default /sanvex/approve).

sv_integrations

This table is created by migration but is not read or written by current core/driver runtime code. Treat it as reserved for future use.

Encryption

Credentials in sv_accounts are encrypted at rest:
  1. A random DEK (data encryption key) encrypts the credential value
  2. The DEK is encrypted with the KEK (key encryption key)
  3. KEK comes from SANVEX_KEK in .env, falling back to APP_KEY
Generate a dedicated KEK:
Add the output to .env:
If no KeyManager is configured (no KEK), credentials are held in memory only and not persisted.