Listoca
Deployment

Database

Migrations, schema changes that installed apps survive, backups and the PowerSync replication slot.

The database is Supabase's Postgres. Its schema lives in supabase/migrations as plain SQL, applied in order.

Applying migrations

SUPABASE_DB_URL=postgresql://postgres:<password>@<host>:5432/postgres bun run db:migrate

Locally, bun run supabase:reset reapplies everything from scratch and seeds the demo users.

Changes installed apps survive

Phones keep old versions of the app for months, with writes queued against the schema they knew:

  • Add columns and tables freely.
  • Never rename or drop in the same release. Make a column nullable and stop using it, then drop it two releases later.
  • A synced table's stream changes the same way: add the new stream, release, remove the old one later.

An upload from an old version that no longer fits is refused. The user sees it under Settings → Sync, with what they wrote.

Backups

The backup service in docker-compose.prod.yml writes a pg_dump every day and keeps 14 days (BACKUP_KEEP_DAYS). Storage's files need their own backup: the volume, or an S3 bucket as Storage's backend. PowerSync's storage database needs none, because it rebuilds from replication. deploy/README.md has the restore steps.

The replication slot

PowerSync reads changes through a logical replication slot. While PowerSync is down, Postgres keeps the WAL for it. Set max_slot_wal_keep_size and watch the slot's lag:

select slot_name, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn))
from pg_replication_slots;

On this page