## Migrations

Use migrations for database schema changes in the managed app repo.

That includes changes like:

- adding tables
- changing columns
- updating indexes or other schema-level database setup

If you are adding tables, this is the workflow to use.

In practice, have the **Engineer** agent work on the schema change and add the migration in the app repository.

## Where Migrations Live

Migrations live in `supabase/migrations/` in the app repository.

## How The Workflow Works

1. Add the migration file in the app repository.
2. Have the Engineer request a deploy so the migration work can reach staging.
3. While the handoff is open, automated checks can lint the migration files.
4. When the change reaches staging (staging publish / Publish to Staging), the staging migration path runs automatically.
5. When those changes are later published to production, the production migration path runs automatically.

## Staging And Production

- shipping a migration to staging applies it to staging
- publishing to production applies it to production

That keeps migrations lined up with the same staging-to-production flow as the app code. Requesting a deploy is the normal agent path to staging; workspace Publish is the path to production.

## Next Steps

- [Supabase](https://docs.cofounder.co/managed-services/supabase)
- [Requesting a deploy](https://docs.cofounder.co/publishing/request-deploy)
- [Publishing](https://docs.cofounder.co/publishing/overview)
- [Environments](https://docs.cofounder.co/publishing/environments)
