Skip to content

Last1 Database Migrations

SQL migration files for the Last1.app Supabase database.

Migration Order

Run these in order (see manifest.json for the CI replay order):

# File Description
0 ci/000_bootstrap.sql CI-only Supabase/RadioCheck stubs (not for production)
1 20260202_1518_supabase_schema.sql Core Last1 schema (orgs, programs, beneficiaries, check-ins) - DO NOT RUN ON SHARED DB
2 20260202_1518_supabase_admin.sql Admin functions and RLS policies
3 20260202_1621_001_last1_radiocheck_bridge.sql Bridge tables for RadioCheck integration (use this for shared DB)

CI Migration Replay

GitHub Actions runs npm run test:migrations on every PR/push to main:

  1. Starts a clean Postgres 16 database
  2. Applies all migrations in manifest.json order (excluding prod hotfixes)
  3. Asserts required tables, columns, indexes, and RPC functions exist

To run locally (requires Postgres):

export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/last1_test
createdb last1_test  # once
npm run test:migrations

Important Notes

  • Shared Database: If using a shared Supabase instance with RadioCheck, only run 001_last1_radiocheck_bridge.sql
  • Separate Database: If Last1 has its own Supabase, run all migrations in order

Naming Convention

Files are named: YYYYMMDD_HHMM_NNN_description.sql - YYYYMMDD = Date created - HHMM = Time created (24hr) - NNN = Sequence number (optional) - description = Brief description in snake_case