1. Documentation
  2. Databases
  3. Schema and migrations
ReadmeGitHub
  • Introduction
  • Quickstart
  • CLI
  • Configuration
  • Identity
  • Branding
  • Themes
  • Monitors
  • Checks and scheduling
  • Metrics and badges
  • Incidents
  • Maintenance
  • Notifications
  • Subscribers
  • React Router
  • Next.js
  • Astro
  • SQLite
  • Cloudflare D1
  • PostgreSQL
  • Schema and migrations
  • Cloudflare
  • Vercel
  • Self-hosting
  • API overview
  • Status endpoints
  • Incident endpoints
  • Maintenance endpoints
  • Subscriber endpoints
  • Badges, feeds and metrics
  • Admin endpoints
  • The check run
  • Uptime and history
  • Automatic incidents
  • Notification delivery
  • Public subscriptions

Schema and migrations

Which migrations to run for SQLite, D1 and PostgreSQL, and what they create.

The migration command depends on the database. Run it against the same database your deployed app uses, before serving requests with a new Heyo Status version:

DatabaseLocal developmentBefore deploying / after an upgrade
SQLiteAutomatic when the adapter is created.Back up the persistent file; starting the updated app applies new migrations.
Cloudflare D1bun run db:migrate in a generated project (or bun dev).bunx wrangler d1 migrations apply <database-name> --remote, then deploy.
PostgreSQLbun run db:migrate once the database is reachable.Run bun run db:migrate with production database credentials, then deploy.

bun run db:migrate is a script in generated projects. Follow the SQLite, D1 or PostgreSQL guide to manage the generated project's database. D1's local migration command does not touch its remote database. Runtime request handlers don't migrate PostgreSQL or D1 for you.

What gets created?

MigrationChange
0000_initialstatus_results (individual checks) and status_daily_summaries (compacted history).
0001_incidents_maintenanceincidents, incident_updates and maintenance_windows.
0002_notification_logDelivery attempt history.
0003_subscribersEmail and webhook subscriptions.
0004_subscriber_uniquenessRemoves duplicate subscriber destinations, then adds a unique index on (type, target).

0004_subscriber_uniqueness deletes duplicate subscriber rows if you upgrade an existing database with duplicates. Back up and review the data before running it in production. Migrations add to the existing schema; you should not recreate the database to upgrade.

These are the main tables after migration:

TableStores
status_resultsEach monitor check, its outcome, latency and timestamp.
status_daily_summariesCompacted counts, downtime and latency per monitor and UTC day.
incidents, incident_updatesIncident state and timeline.
maintenance_windowsPlanned work and affected monitors.
notification_logDelivery results, not webhook credentials or payloads.
subscribersDestinations and confirmation state.

Timestamps are stored as epoch milliseconds. The database schema is not created by Drizzle's migration CLI: Heyo Status supplies its own migrations. Don't copy only a CREATE TABLE snippet from this page; use the migration workflow for your adapter.

How are applied migrations tracked?

SQLite and the programmatic PostgreSQL adapter record applied IDs in __heyo_status_migrations. They skip those IDs on subsequent runs. A programmatic D1 database.migrate() call uses that table too, but generated Cloudflare projects use Wrangler to apply SQL from migrations/. Wrangler keeps its own migration history; it does not mark IDs in __heyo_status_migrations. Don't alternate between Wrangler and database.migrate() on the same D1 database.

The generator copies D1 SQL files into the project when it creates it. Updating the runtime package does not copy any newly added SQL files into an existing project. On upgrade, add new numbered SQL files from the matching generator release to migrations/, then run Wrangler's local and remote migration commands before deploying the updated runtime.

Using a custom database adapter

If none of the built-in adapters fit, pass an implementation of StatusDatabaseAdapter as database. The type is exported from @heyo-sh/heyo-status/types. Your adapter must implement the full contract, including check history, incidents, maintenance, subscribers and the notification log; configuration rejects incomplete adapters.

Heyo Status doesn't create tables for a custom adapter. Provide your own migration process. To let heyo-status db migrate invoke it, expose an optional migrate(): Promise<void> method; otherwise don't treat the CLI's "embedded migrations" message as proof that your schema exists.

For a database that can only be opened after a request binding or secret becomes available, wrap its construction in lazyStatusDatabase(). Its migrate() forwards to the resolved adapter, but throws if that adapter has no migration method.

PostgreSQL< PreviousCloudflareNext >

Powered by heyo

On this page

What gets created?How are applied migrations tracked?Using a custom database adapter