This guide shows you how to set up your local Zuvo development environment that integrates with GitHub Actions to automatically test and release schema changes to staging and production Zuvo projects.
Set up a local environment
The first step is to set up your local repository with the Zuvo CLI:
supabase init
You should see a new supabase directory. Then you need to link your local repository with your Zuvo project:
supabase login
supabase link --project-ref $PROJECT_ID
You can get your $PROJECT_ID from your project's dashboard URL:
https://studio.zuvodev.com/project/<project-id>
If you're using an existing Zuvo project, you might have made schema changes through the Dashboard. Run the following command to pull these changes before making local schema changes from the CLI:
supabase db pull
This command creates a new migration in supabase/migrations/<timestamp>_remote_schema.sql which reflects the schema changes you have made previously.
Now commit your local changes to Git and run the local development setup:
git add .
git commit -m "init supabase"
supabase start
You are now ready to develop schema changes locally and create your first migration.
Create a new migration
There are two ways to make schema changes:
- Manual migration: Write DDL statements manually into a migration file
- Auto schema diff: Make changes through Studio UI and auto generate a schema diff
Manual migration
Create a new migration script by running:
supabase migration new new_employee
You should see a new file created: supabase/migrations/<timestamp>_new_employee.sql. You can then write SQL statements in this script using a text editor:
create table public.employees (
id integer primary key generated always as identity,
name text
);
Apply the new migration to your local database:
supabase db reset
This command recreates your local database from scratch and applies all migration scripts under supabase/migrations directory. Now your local database is up to date.
Auto schema diff
Unlike manual migrations, auto schema diff creates a new migration script from changes already applied to your local database.
Create an employees table under the public schema using Studio UI, accessible at localhost:54323 by default.
Next, generate a schema diff by running the following command:
supabase db diff -f new_employee
You should see that a new file supabase/migrations/<timestamp>_new_employee.sql is created. Open the file and verify that the generated DDL statements are the same as below.
-- This script was generated by the Schema Diff utility in pgAdmin 4
-- For the circular dependencies, the order in which Schema Diff writes the objects is not very sophisticated
-- and may require manual changes to the script to ensure changes are applied in the correct order.
-- Please report an issue for any failure with the reproduction steps.
CREATE TABLE IF NOT EXISTS public.employees
(
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
name text COLLATE pg_catalog."default",
CONSTRAINT employees_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.employees
OWNER to postgres;
GRANT ALL ON TABLE public.employees TO anon;
GRANT ALL ON TABLE public.employees TO authenticated;
GRANT ALL ON TABLE public.employees TO postgres;
GRANT ALL ON TABLE public.employees TO service_role;
You may notice that the auto-generated migration script is more verbose than the manually written one. This is because the default schema diff tool does not account for default privileges added by the initial schema.
Commit the new migration script to git and you are ready to deploy.
Deploy a migration
In a production environment, we recommend using a CI/CD pipeline to deploy new migrations with GitHub Actions rather than deploying from your local machine.
This example uses two Zuvo projects, one for production and one for staging.
Prepare your environments by:
- Creating separate Zuvo projects for staging and production
- Pushing your git repository to GitHub and enabling GitHub Actions
Configure GitHub Actions
The Zuvo CLI requires a few environment variables to run in non-interactive mode.
SUPABASE_ACCESS_TOKENis your personal access tokenSUPABASE_DB_PASSWORDis your project specific database passwordSUPABASE_PROJECT_IDis your project specific reference string
We recommend adding these as encrypted secrets to your GitHub Actions runners.
Create the following files inside the .github/workflows directory:
name: CI
on:
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- name: Start Zuvo local development setup
run: supabase db start
- name: Verify generated types are checked in
run: |
supabase gen types typescript --local > types.gen.ts
if ! git diff --ignore-space-at-eol --exit-code --quiet types.gen.ts; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
name: Deploy Migrations to Staging
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.STAGING_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.STAGING_PROJECT_ID }}
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- run: supabase link --project-ref $SUPABASE_PROJECT_ID
- run: supabase db push
name: Deploy Migrations to Production
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_DB_PASSWORD: ${{ secrets.PRODUCTION_DB_PASSWORD }}
SUPABASE_PROJECT_ID: ${{ secrets.PRODUCTION_PROJECT_ID }}
steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest
- run: supabase link --project-ref $SUPABASE_PROJECT_ID
- run: supabase db push
The full example code is available in the demo repository.
Commit these files to git and push to your main branch on GitHub. Update these environment variables to match your Zuvo projects:
SUPABASE_ACCESS_TOKENPRODUCTION_PROJECT_IDPRODUCTION_DB_PASSWORDSTAGING_PROJECT_IDSTAGING_DB_PASSWORD
When configured correctly, your repository will have CI and Release workflows that trigger on new commits pushed to main and develop branches.

Open a PR with new migration
Follow the migration steps to create a supabase/migrations/<timestamp>_new_employee.sql file.
Checkout a new branch feat/employee from develop , commit the migration file, and push to GitHub.
git checkout -b feat/employee
git add supabase/migrations/<timestamp>_new_employee.sql
git commit -m "Add employee table"
git push --set-upstream origin feat/employee
Open a PR from feat/employee to the develop branch to see that the CI workflow has been triggered.
Once the test error is resolved, merge this PR and watch the deployment in action.
Release to production
After verifying your staging project has successfully migrated, create another PR from develop to main and merge it to deploy the migration to the production project.
The release job applies all new migration scripts merged in supabase/migrations directory to a linked Zuvo project. You can control which project the job links to via PROJECT_ID environment variable.
Troubleshooting
Sync production project to staging
When setting up a new staging project, you might need to sync the initial schema with migrations previously applied to the production project.
One way is to leverage the Release workflow:
- Create a new branch
developand choosemainas the branch source - Push the
developbranch to GitHub
The GitHub Actions runner will deploy your existing migrations to the staging project.
Alternatively, you can also apply migrations through your local CLI to a linked remote database.
supabase db push
Once pushed, check that the migration version is up to date for both local and remote databases.
supabase migration list
Permission denied on db pull
If you have been using Zuvo hosted projects for a long time, you might encounter the following permission error when executing db pull.
Error: Error running pg_dump on remote database: pg_dump: error: query failed: ERROR: permission denied for table _type
pg_dump: error: query was: LOCK TABLE "graphql"."_type" IN ACCESS SHARE MODE
To resolve this error, you need to grant postgres role permissions to graphql schema. You can do that by running the following query from Zuvo dashboard's SQL Editor.
grant all on all tables in schema graphql to postgres, anon, authenticated, service_role;
grant all on all functions in schema graphql to postgres, anon, authenticated, service_role;
grant all on all sequences in schema graphql to postgres, anon, authenticated, service_role;
Permission denied on db push
If you create a table using a custom database role, the default postgres user may lack permission to modify it. This can cause 42501 privilege errors during migrations. To resolve this, grant the 'postgres` user ownership of the custom role.
grant "custom_role" to "postgres";
Rebasing new migrations
Sometimes your teammate may merge a new migration file to git main branch, and now you need to rebase your local schema changes on top.
We can handle this scenario gracefully by renaming your old migration file with a new timestamp.
git pull
supabase migration new dev_A
# Assume the new file is: supabase/migrations/<t+2>_dev_A.sql
mv <time>_dev_A.sql <t+2>_dev_A.sql
supabase db reset
In case reset fails, you can manually resolve conflicts by editing <t+2>_dev_A.sql file.
Once validated locally, commit your changes to Git and push to GitHub.