The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Added more clarity / detail to remote/local development for Branching (#19583)
Jonathan Summers-Muir16120e690b0f
diff --git a/apps/docs/pages/guides/platform/branching.mdx b/apps/docs/pages/guides/platform/branching.mdxindex 08fdbcb94bf..a3b0dd13f17 100644--- a/apps/docs/pages/guides/platform/branching.mdx+++ b/apps/docs/pages/guides/platform/branching.mdx@@ -7,43 +7,23 @@ export const meta = {subtitle: 'Use Supabase Branches to test and preview changes',}-<Admonition type="note" label="Branching is only available on the Pro Plan and above.">+Use branching to safely and easily experiment with changes to your Supabase projects.-</Admonition>--<Admonition type="caution" label="Region issues impacting reliability">+<Admonition type="caution" label="Branching available for Early Access, available on the Pro Plan and above.">-Currently, there is a known issue with the reliability of Preview Branches being deployed in the following regions:+We do not recommended Branching in a production environment while it is in Early Access. To try branching, [request access here](https://forms.supabase.com/branching-request). We are working our upstream provider to improve the stability in the following regions:- South East Asia (Singapore)- South Asia (Mumbai)-- Central EU (Frankfurt) regions--We are working on the stability fixes with the upstream provider.--Currently, it is advised to use a Supabase Project that is not using these regions.--</Admonition>--Use branching to safely and easily experiment with changes to your Supabase project.--Supabase branches work like Git branches. They let you create and test changes like new configurations, database schemas, or features in a separate, temporary instance without affecting your production setup.--When you're ready to ship your changes, merge your branch to update your production instance with the new changes.--If you understand Git, you already understand Supabase Branching.--<Admonition type="caution" label="Branching is in Alpha">--It is not recommended to use Branching in a production environment.--Branching is an Alpha feature. To try out branching for non-production experiments, [request access here](https://forms.supabase.com/branching-request).+- Central EU (Frankfurt)</Admonition>## How branching works-Supabase projects can consist of multiple Preview Branches. All Preview Branches are backed by an isolated Supabase instance. Each instance contains all Supabase features, and has its own API credentials.+Supabase Branching works with Git. You can test changes in a separate, temporary environment without affecting your production setup. When you're ready to ship your changes, merge your branch to update your production instance with the new changes.++You can run multiple Preview Branches for every Supabase project. Branches contain all the Supabase features with their own API credentials. Preview Environments pause automatically after 5 minutes of inactivity.<figure className="max-w-[700px] mx-auto"><Image@@ -56,30 +36,16 @@ Supabase projects can consist of multiple Preview Branches. All Preview Branchesalt="Each branch has a separate Supabase instance."src="/docs/img/guides/platform/branching/github-workflow-without-branching--light.jpg?v=1"/>- <figcaption>Each branch has a separate Supabase instance.</figcaption>+ <figcaption>Each Branch is a separate environment.</figcaption></figure>-Supabase branching works like Git branching, with one main Production branch. Preview Branches branch off your Production branch and contain proposed changes. These changes can then be merged into Production.--When you create a Preview Branch, the SQL migration files from your Production branch are run on the new Preview Branch. The Preview Branch then reflects your current Production branch schema.--The Preview Branch will also be [seeded with sample data](#seeding-behaviour) if a seed file exists.--By creating new SQL migrations in a Preview Branch to propose schema changes, those changes can then be merged into your Production branch. These changes then run the new migrations on your Supabase Production branch. This is exactly how Git branches work: experiment on a feature branch and merge back into Production when you're finished.--<Admonition type="note" label="Schema-only changes">+### Branching workflow- Only *schema* changes are captured in preview branches.-- Preview Branch instances contain no data by default. You must include a seed file to seed your preview instance with sample data when the Preview Branch is created. Future versions of Branching may allow for automated data seeding and cloning.--</Admonition>+Preview Branch instances contain no data by default. You must include a seed file to seed your preview instance with sample data when the Preview Branch is created. Future versions of Branching may allow for automated data seeding and cloning after we are confident that we can provide safe data masking.## Git providers-To facilitate Supabase Branching, your Supabase project will be connected to a Git repository via an integration.--Supabase Branching works with [GitHub](#branching-with-github). Future iterations may support other Git providers. If you are interested in other Git providers or a non-Git-based workflow, join the discussions for [GitLab Branching, BitBucket Branching, and non-Git based Branching](https://github.com/orgs/supabase/discussions/18936).+To manage code changes, your Supabase project must be connected to a Git repository. At this stage we only support [GitHub](#branching-with-github). If you are interested in other Git providers, join the [discussion](<(https://github.com/orgs/supabase/discussions/18936)>) for GitLab, BitBucket, and non-Git based Branching.### Branching with GitHub@@ -91,6 +57,8 @@ You can create a corresponding Preview Branch for any Git branch in your repositThe Preview Branch is also seeded with sample data based on `./supabase/seed.sql`, if that file exists.+Supabase Branching follows the [Trunk Based Development](https://trunkbaseddevelopment.com/) workflow, with one main Production branch and multiple development branches:+<figure className="max-w-[700px] mx-auto"><ImageclassName="hidden dark:block"@@ -107,7 +75,15 @@ The Preview Branch is also seeded with sample data based on `./supabase/seed.sql</figure>-Each time a commit is pushed with new migrations in the `./supabase/migrations` directory, the migrations are run on the matching preview instance.+### Production Branch++In Git, you have a Production Branch (typically this is `main`, `master`, `prod`, etc). This should also be your Supabase project's Production Branch.++### Preview Branches++After connecting your Supabase project to one of the supported [Git providers](#git-providers), a corresponding Supabase Preview will be created whenever a new Git branch is created.++The Git integration can read files from your Git provider, watching every commit and pull request. Each time a commit is pushed with new migrations in the `./supabase/migrations` directory, the migrations are run on the matching Supabase Preview environment:<figure className="max-w-[700px] mx-auto"><Image@@ -125,112 +101,124 @@ Each time a commit is pushed with new migrations in the `./supabase/migrations`</figure>-## Alternatives to branching+### Data changes-If you don’t turn on branching, your Supabase project continues to work as a single branch, on a single instance. You have a single set of API keys for each project, and no preview instances are created. It's the Git equivalent of working directly on the `main` branch.+The Preview Branch is seeded with sample data based on `./supabase/seed.sql`, if that file exists.-If you prefer not to use branching, you can manage your environments and tests in other ways:+For security reasons, Preview Branches do not contain production data. Future versions of Branching may allow for automated data cloning after we are confident that we can provide safe data masking.-1. ##### Host a project per environment, and test against a staging project+<Admonition type="note" label="Data changes are not merged into production." />- Create multiple projects on Supabase with the same schema. Use one project as a staging environment to test any changes. Then migrate tested changes to the production project.+### Merging Production changes-2. ##### Host a single production project, and test locally+When you merge your Git branch into the production branch, all changes will be applied to your Production environment.- Create a single project to host your production instance. Test any changes locally, then run the migrations against your hosted production project.+### Git providers-You can also combine both strategies to perform both local and staging tests.+We currently support [GitHub](#branching-with-github). If you are interested in other Git providers, join the [discussion](<(https://github.com/orgs/supabase/discussions/18936)>) for GitLab, BitBucket, and non-Git based Branching.## How to use Supabase Branching-<Admonition type="note" label="Github integration required">+Supabase Branching requires a hosted [Git provider](#git-providers). Follow these steps to connect your Supabase project to a Git provider, and enable branching.-Supabase branching requires the GitHub integration. Your application must be developed in a GitHub repository.+### Preparing your Git repository-</Admonition>+You can use the [Supabase CLI](/docs/guides/cli) to manage changes inside a local `./supabase` directory:-### Preparing your GitHub repository+<Tabs+ scrollable+ size="small"+ type="underlined"+ defaultActiveId="existing"+ queryGroup="platform"+>+<TabPanel id="existing" label="Existing project">-You need a GitHub repository to use Supabase branching. The `./supabase` directory in your repository contains your SQL migration files and your database seed file.--To start:--- If you don't have a new project, [set one up using the example template](#set-up-a-new-project-with-the-example-template).-- If you have an existing project, [make sure your database-related files are up to date](#set-up-an-existing-project-for-branching).+<StepHikeCompact>+ <StepHikeCompact.Step step={1}>+ <StepHikeCompact.Details title="Initialize Supabase locally" fullWidth>-#### Set up a new project with the example template+ If you don't have a `./supabase` directory, you can create one:-Use the Next.js example template to try out branching. This template includes sample migration and seed files to get you started.+ <CH.Code lineNumbers={false}>-Run the following command in your terminal to clone the example:+ ```markdown+ supabase init+ ```-```bash-npx create-next-app -e with-supabase-```+ </CH.Code>+ </StepHikeCompact.Details>+ </StepHikeCompact.Step>-Push your new project to a GitHub repo. For more information, see the GitHub guides on [creating](https://docs.github.com/en/get-started/quickstart/create-a-repo) and [pushing code](https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository) to a new repository.+ <StepHikeCompact.Step step={2}>+ <StepHikeCompact.Details title="Sync your database migration" fullWidth>-#### Set up an existing project for branching+ Sync your database changes using `supabase db pull`. You can find your database URL in your [database settings](https://supabase.com/dashboard/project/_/settings/database), under the URI tab of the Connection String settings panel.-Before enabling branching on an existing project, make sure your database-related files are up to date. You need a current snapshot of your existing database, so newer migration files have a foundation to run on top of.+ <CH.Code lineNumbers={false}>-<Admonition type="caution" label="Get set up before turning on branching">+ ```markdown+ supabase db pull --db-url <db_url>-Setting up the initial state incorrectly can cause migrations to be wrongly applied.+ # Your Database URL looks something like:+ # postgresql://username:[email protected]:5432/postgres+ ```-Follow the instructions below **before turning on Supabase branching**.+ </CH.Code>-</Admonition>+ </StepHikeCompact.Details>+ </StepHikeCompact.Step>-##### If your migration files are already in GitHub, under `./supabase/migrations`:+ <StepHikeCompact.Step step={3}>+ <StepHikeCompact.Details title="Commit the `supabase` directory to Git" fullWidth>-If your migration files are up to date with your production database, you don’t need to do anything. You can now turn on branching.+ Commit the `supabase` directory to Git, and push your changes to your remote repository.-##### If you don't have migration files in GitHub:+ <CH.Code lineNumbers={false}>-You need to take a snapshot of your database. Log into Supabase from the [command line client](/docs/guides/cli) and pull the relevant files. Then commit them to GitHub:+ ```bash+ git add supabase+ git commit -m "Initial migration"+ git push+ ```-1. Inside your project directory, initialize your configuration for Supabase local development:+ </CH.Code>- ```bash- supabase init- ```-2. Pull down database-related files. You can find your database URL in your [database settings](https://supabase.com/dashboard/project/_/settings/database), under the URI tab of the Connection String settings panel. It will look something like `postgresql://username:[email protected]:5432/postgres`+ </StepHikeCompact.Details>+ </StepHikeCompact.Step>- ```bash- supabase db pull --db-url <db_url>- ```+</StepHikeCompact>-3. Commit the `supabase` directory to Git, and push your changes to your remote repository.+</TabPanel>+<TabPanel id="new" label="New Project">- ```bash- git add supabase- git commit -m "Initial migration"- git push- ```+Use the Next.js example template to try out branching. This template includes sample migration and seed files to get you started. Run the following command in your terminal to clone the example:-### Enable Supabase branching+```bash+npx create-next-app -e with-supabase+```-Once your repository is [correctly prepared](#set-up-an-existing-project-for-branching), you can enable branching from the Supabase dashboard.+Push your new project to a GitHub repo. For more information, see the GitHub guides on [creating](https://docs.github.com/en/get-started/quickstart/create-a-repo) and [pushing code](https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository) to a new repository.-<Admonition type="caution" label="Prepare your repo before enabling Branching">+</TabPanel>+</Tabs>-Before turning on branching, make sure your [GitHub repository is prepared](#set-up-an-existing-project-for-branching). If your repository doesn’t have all the migration files, your production branch could run an incomplete set of migrations.+### Enable Supabase Branching-</Admonition>+Once your repository is [correctly prepared](#preparing-your-git-repository), you can enable branching from the Supabase dashboard.-<Admonition type="note" label="Branching is early access only">+<Admonition type="caution" label="Prepare your GitHub repository before enabling Branching">-Sign up for early access [here](https://forms.supabase.com/branching-request).+If your repository doesn't have all the migration files, your production branch could run an incomplete set of migrations. Make sure your [GitHub repository is prepared](#preparing-your-git-repository).</Admonition><StepHikeCompact><StepHikeCompact.Step step={1}>- <StepHikeCompact.Details title="Select the project you want to use, then click `Enable branching`" fullWidth>+ <StepHikeCompact.Details title="Inside your Supabase project, click `Enable branching`" fullWidth>- If you’re prompted to join the waitlist, click `Join waitlist`. Access will be expanded as branching graduates from alpha testing.+ If you're prompted to join the waitlist, click `Join waitlist`. We're rolling out Branching to users in batches.<figure className="max-w-[520px]"><Image src="/docs/img/guides/platform/branching/enable-supabase-branching-opt-in-popover.jpg?v=1" />@@ -240,15 +228,17 @@ Sign up for early access [here](https://forms.supabase.com/branching-request).</StepHikeCompact.Step><StepHikeCompact.Step step={2}>- <StepHikeCompact.Details title="If you see the following dialog, you’re in the alpha testing group" fullWidth>+ <StepHikeCompact.Details title="Install the GitHub integration" fullWidth>++ If you have been granted early access, once when clicking `Enable branching` you will see the following dialog:<figure className="max-w-[520px]"><Image src="/docs/img/guides/platform/branching/enable-supabase-branching-opt-in-install-github.jpg?v=1" /></figure>- If you don’t have the GitHub integration installed, click `Install GitHub Integration`. The integration is required to run migration files and the optional database seed file.+ If you don't have the GitHub integration installed, click `Install GitHub Integration`. The integration is required to run migration files and the optional database seed file.- You’re taken to the GitHub integration page. Click `Install`.+ You're taken to the GitHub integration page. Click `Install`.<figure className="max-w-[520px]"><Image src="/docs/img/guides/platform/branching/enable-supabase-branching-opt-in-install-github-permissions.jpg?v=1" />@@ -266,15 +256,14 @@ Sign up for early access [here](https://forms.supabase.com/branching-request).</StepHikeCompact.Step><StepHikeCompact.Step step={3}>- <StepHikeCompact.Details title="If you see the following dialog, you’re in the alpha testing group" fullWidth>+ <StepHikeCompact.Details title="If you see the following dialog, you're in the Early Access group" fullWidth>You should now see a popover with the GitHub Connection details shown.Type in the branch you want to use for production. The name of the branch will be validated to make sure it exists in your GitHub repository.- <Admonition type="caution">+ <Admonition type="caution" label="Your production branch can't be changed while branching is enabled.">- Your production branch can’t be changed while branching is enabled.To change your production branch, you need to disable branching and re-enable it with a different branch.</Admonition>@@ -337,11 +326,9 @@ Preview branches are automatically created for each pull request, but you can alType in the branch name you want to add. Click `Create branch` to confirm.- <Admonition type="note">-- **Only branches from the repository can be used to create a Preview Branch**+ <Admonition type="note" label="Only branches from the repository can be used to create a Preview Branch">- Git branches from external contributors currently can’t support a Preview Branch+ Git branches from external contributors currently can't support a Preview Branch</Admonition>@@ -354,93 +341,180 @@ Preview branches are automatically created for each pull request, but you can al</StepHikeCompact>-### Develop your app with Supabase branches+### Make changes to your branch-Supabase branching uses the state of your GitHub repository to apply migrations and seed preview instances. It checks the `supabase` directory at the top level of your repository.--The `supabase` directory should include:+The Git integration watches for changes in the `supabase` directory. This includes:- All SQL migration files, under the subdirectory `migrations`- An optional `seed.sql` file, used to seed preview instances with sample data-The GitHub integration watches for changes in the `migrations` directory. When it detects a new migration file, it runs the new migration against the matching preview instance.+You can create new migrations either [locally](#develop-locally) or [remotely](#develop-remotely). Local development is recommended.-You can create new migrations either [locally](#develop-locally) or [remotely](#develop-remotely).+<Tabs+ scrollable+ size="small"+ type="underlined"+ defaultActiveId="local-dev"+ queryGroup="making-updates"+>+<TabPanel id="local-dev" label="Local Development">-Local development is recommended for developers familiar with the Supabase CLI, who want to test changes on their local machine. Remote development is recommended if you don’t want to run Supabase locally, or if you want to collaborate with team members via the dashboard interface.+The Supabase CLI provides two options: [manual migrations](https://supabase.com/docs/guides/cli/local-development#database-migrations) and [generated migrations](https://supabase.com/docs/guides/cli/local-development#diffing-changes) using Supabase's local studio and the `supabase db-diff` command. Let's use the latter and push the change to our Preview Branch:-#### Develop locally+<StepHikeCompact>-You can develop locally by running Supabase on your local machine. You’ll have a database running locally, and another database running remotely on the preview branch.+ <StepHikeCompact.Step step={1}>+ <StepHikeCompact.Details title="Make schema changes locally" fullWidth>++ Start supabase locally:-You can experiment on your local database by [writing SQL migrations yourself](https://supabase.com/docs/guides/cli/local-development#database-migrations). You can also [auto-generate migration files by using Supabase’s local studio](https://supabase.com/docs/guides/cli/local-development#diffing-changes) and the `supabase db-diff` command.+ <CH.Code lineNumbers={false}>-Once you’re confident in your migration files, push your changes to your remote GitHub repository to update the preview branch.+ ```bash+ supabase start+ ```-To create and push local migrations:+ </CH.Code>-1. ##### Create a new migration file.+ Then proceed to [localhost:54323](http://localhost:54323) to access your local Supabase dashboard.- ```json- supabase migration new "new_feature"- ```+ You can make changes in either the [Table Editor](http://localhost:54323/project/default/editor) or the [SQL Editor]((http://localhost:54323/project/default/sql)).-2. ##### Add SQL statements to your new migration file.+ </StepHikeCompact.Details>+ </StepHikeCompact.Step>- You can manually edit the new migration file, or use [local studio](https://supabase.com/docs/guides/cli/local-development#diffing-changes) and diff the changes.+ <StepHikeCompact.Step step={2}>+ <StepHikeCompact.Details title="Generate a migration file" fullWidth>- ```sql- create table employees (- id integer primary key generated always as identity,- name text- )- ```+ Once you are finished making database changes, run `supabase db diff` to create a new migration file. For example:-3. ##### Commit and push your migration file.+ <CH.Code lineNumbers={false}>- ```sql- git add supabase/migrations- git commit -m "Add employees table"- git push --set-upstream origin new-employee- ```+ ```bash+ supabase db diff -f "add_employees_table"+ ```-Supabase’s GitHub integration detects the new migration and runs it against the branch instance.+ </CH.Code>-It can take up to 10 minutes for migrations to be applied. If you have a PR for your branch, errors are reflected in the GitHub check run status and in a PR comment.+ This will create a SQL file called `./supabase/migrations/[timestamp]add_employees_table.sql`. This file will reflect the changes that you made in your local dashboard.-If you need to reset your database to a clean state (that is, discard any changes that aren’t reflected in the migration files), run `supabase db reset` locally. Then, delete the preview branch and recreate it.+ If you want to continue making change, you can manually edit this migration file, then use the `db reset` command to pick up your edits:-#### Develop remotely+ <CH.Code lineNumbers={false}>-As an alternative to developing locally, you can make changes on your remote Supabase dashboard. You can then pull these changes to your local machine and commit them to GitHub.+ ```bash+ supabase db reset+ ```-<Admonition type="note">+ </CH.Code>-Changes must be locally pulled and committed to keep your GitHub repository state in sync.+ This will reset the database and run all the migrations again. The local dashboard at [localhost:54323](http://localhost:54323) will reflect the new changes you made.-Dashboard changes aren’t automatically reflected in your repository. If you’d like to see automatic syncing in a future release, [join the discussion](https://github.com/orgs/supabase/discussions/18937).+ </StepHikeCompact.Details>+ </StepHikeCompact.Step>++ <StepHikeCompact.Step step={3}>+ <StepHikeCompact.Details title="Commit your changes and push." fullWidth>++ Commit and push your migration file to your remote GitHub repository. For example:++ <CH.Code lineNumbers={false}>++ ```bash+ git add supabase/migrations+ git commit -m "Add employees table"+ git push --set-upstream origin new-employee+ ```++ </CH.Code>++ The Supabase integration detects the new migration and runs it on the remote Preview Branch. It can take up to 10 minutes for migrations to be applied. If you have a PR for your branch, errors are reflected in the GitHub check run status and in a PR comment.++ If you need to reset your database to a clean state (that is, discard any changes that aren't reflected in the migration files), run `supabase db reset` locally. Then, delete the preview branch and recreate it.++ </StepHikeCompact.Details>++ </StepHikeCompact.Step>++</StepHikeCompact>++</TabPanel>++<TabPanel id="remote-dev" label="Remote Development">++As an alternative to developing locally, you can make changes on your remote Supabase dashboard. You can then pull these changes to your local machine and commit them to GitHub.++<Admonition type="note" label="Changes must be locally pulled and committed to keep your Git repository state in sync.">++Dashboard changes aren't automatically reflected in your Git repository. If you'd like to see automatic syncing in a future release, [join the discussion](https://github.com/orgs/supabase/discussions/18937).</Admonition>-1. Click on the active branch in the top bar to open the dropdown menu. Select the branch you want to use.+<StepHikeCompact>+ <StepHikeCompact.Step step={1}>+ <StepHikeCompact.Details title="Select the branch you want to use." fullWidth>++ Select the branch you wish to use in your Supabase [project](https://supabase.com/dashboard/project/_).++ <figure className="max-w-[520px]">+ <Image src="/docs/img/guides/platform/branching/develop-your-app-develop-remotely.jpg?v=1" />+ </figure>++ </StepHikeCompact.Details>+ </StepHikeCompact.Step>++ <StepHikeCompact.Step step={2}>+ <StepHikeCompact.Details title="Make changes to your database schema." fullWidth>++ Make changes to your schema with either with the [Table Editor](https://supabase.com/dashboard/project/_/editor) or the [SQL Editor]((https://supabase.com/dashboard/project/_/sql)).++ </StepHikeCompact.Details>+ </StepHikeCompact.Step>++ <StepHikeCompact.Step step={3}>+ <StepHikeCompact.Details title="Check you have the password for the Preview Branch database." fullWidth>++ If you don't know the password, you must Reset the database password so you know the password. Go to the [database setting page](https://supabase.com/dashboard/project/_/settings/database) and click `Reset database password`.++ Save the new password securely for future use.++ </StepHikeCompact.Details>+ </StepHikeCompact.Step>++ <StepHikeCompact.Step step={4}>+ <StepHikeCompact.Details title="Pull changes from remote database." fullWidth>++ In your local terminal, navigate to the directory for your Supabase project and use the Supabase CLI to pull changes from your branch to your local migrations directory.++ Make sure to use the database URL for your branch:++ <CH.Code lineNumbers={false}>- <figure className="max-w-[520px]">- <Image src="/docs/img/guides/platform/branching/develop-your-app-develop-remotely.jpg?v=1" />- </figure>+ ```bash+ supabase db pull --db-url "postgres://postgres:[password]@db.[branch-ref].supabase.co:5432/postgres"+ ```-2. Make changes to your database schema from the Supabase dashboard.-3. Reset database password for the branch. To do this, navigate to `https://supabase.com/dashboard/project/[branch-ref]/settings/database` and click **Reset database password**. Save the new password for use in the next step.-4. In your terminal, navigate to the directory for your Supabase project. Use the Supabase client to pull changes from your branch to your local migrations directory. Make sure to use the database URL for your branch.+ </CH.Code>- ```bash- supabase db pull --db-url "postgres://postgres:[password]@db.[branch-ref].supabase.co:5432/postgres"- ```+ </StepHikeCompact.Details>+ </StepHikeCompact.Step>++ <StepHikeCompact.Step step={5}>+ <StepHikeCompact.Details title="Commit and push your migration file." fullWidth>++ No new migrations will be run on your remote Preview Branch after pushing your changes. This is expected, because your database is already up-to-date, based on the changes you made in the dashboard. But this ensures that your migration files are in GitHub, so they can be correctly merged into production.++ </StepHikeCompact.Details>+ </StepHikeCompact.Step>++</StepHikeCompact>-5. Commit and push your migration file. No new migrations are run. This is expected, because your database is already up-to-date, based on the changes you made in the dashboard. But this ensures that your migration files are in GitHub, so they can be correctly merged into production.+</TabPanel>+</Tabs>### Open a pull request-When you open a pull request on GitHub, the Supabase integration automatically checks for a matching preview branch. If one doesn’t exist, it gets created.+When you open a pull request on GitHub, the Supabase integration automatically checks for a matching preview branch. If one doesn't exist, it gets created.A comment is added to your PR with the deployment status of your preview branch. Statuses are shown separately for Database, Services, and APIs.@@ -450,13 +524,11 @@ A comment is added to your PR with the deployment status of your preview branch.<figcaption>Supabase GitHub integration will comment on your PR with the status of your Preview Branch, including whether migrations have successfully run.</figcaption></figure>-Every time a new commit is pushed that changes the migration files in `./supabase/migrations`, the new migrations are run against the preview branch. You can check the status of these runs in the comment’s Tasks table.+Every time a new commit is pushed that changes the migration files in `./supabase/migrations`, the new migrations are run against the preview branch. You can check the status of these runs in the comment's Tasks table.-#### GitHub required check setting+### Preventing migration failures-We highly recommend turning on a ‘required check’ for the Supabase integration. You can do this from your GitHub repository settings.--This prevents PRs from being merged when migration checks fail, and stops invalid migrations from being merged into your production branch.+We highly recommend turning on a 'required check' for the Supabase integration. You can do this from your GitHub repository settings. This prevents PRs from being merged when migration checks fail, and stops invalid migrations from being merged into your production branch.<figure className="max-w-[700px] mx-auto"><Image src="/docs/img/guides/platform/branching/github-required-check.jpg?v=1" />@@ -476,7 +548,7 @@ The preview branch has a record of which migrations have been applied, and only### Rolling back migrations-You might want to roll back changes you’ve made in an earlier migration change. For example, you may have pushed a migration file containing schema changes you no longer want.+You might want to roll back changes you've made in an earlier migration change. For example, you may have pushed a migration file containing schema changes you no longer want.To fix this, push your latest changes, then delete the preview branch in Supabase and reopen it.@@ -502,13 +574,13 @@ To check the error message, see the Supabase integration comment on your PR.If you have multiple preview branches, each preview branch might contain different schema changes. This is similar to Git branches, where each branch might contain different code changes.-When a preview branch is merged into the production branch, it creates a schema drift between the production branch and the preview branches you haven’t merged yet.+When a preview branch is merged into the production branch, it creates a schema drift between the production branch and the preview branches you haven't merged yet.You can solve thse conflicts the way you would solve normal Git Conflicts: merge or rebase from your production Git branch to your preview Git branch. Since migrations are applied sequentially, ensure that migration files are timestamped correctly after the rebase. Changes that build on top of earlier changes should always have later timestamps.### Changing Production Branch-It’s not possible to change the Git branch used as the Production branch for Supabase Branching. The only way to change it is to disable and re-enable branching. See [Disable Branching](#disable-branching).+It's not possible to change the Git branch used as the Production branch for Supabase Branching. The only way to change it is to disable and re-enable branching. See [Disable Branching](#disable-branching).## Branching and hosting providers@@ -518,9 +590,7 @@ With the Supabase branching integration, you can sync the Git branch used by the### Vercel-<Admonition type="note">-- Vercel Branching support is in development.+<Admonition type="note" label="Vercel Branching support is in development.">The Vercel Integration for Supabase branching is under development. To express your interest, [join the discussion on GitHub discussions](https://github.com/orgs/supabase/discussions/18938).@@ -529,9 +599,9 @@ With the Supabase branching integration, you can sync the Git branch used by theInstall the Vercel integration:- From the [Vercel marketplace](https://vercel.com/integrations/supabase-v2) or-- By clicking the blue `Deploy` button in a Supabase example app’s `README` file+- By clicking the blue `Deploy` button in a Supabase example app's `README` file-<Admonition type="note">+<Admonition type="note" label="Vercel GitHub integration also required.">For branching to work with Vercel, you also need the [Vercel GitHub integration](https://vercel.com/docs/deployments/git/vercel-for-github).@@ -541,11 +611,27 @@ Supabase automatically updates your Vercel project with the correct environment### Netlify-A Netlify integration is under consideration. If you’re interested in branching with Netlify, [join the GitHub discussion](https://github.com/orgs/supabase/discussions/18938).+A Netlify integration is under consideration. If you're interested in branching with Netlify, [join the GitHub discussion](https://github.com/orgs/supabase/discussions/18938).++## Alternatives to branching++If you don't turn on branching, your Supabase project continues to work as a single branch, on a single instance. You have a single set of API keys for each project, and no preview instances are created. It's the Git equivalent of working directly on the `main` branch.++If you prefer not to use branching, you can manage your environments and tests in other ways:++1. ##### Host a project per environment, and test against a staging project++ Create multiple projects on Supabase with the same schema. Use one project as a staging environment to test any changes. Then migrate tested changes to the production project.++2. ##### Host a single production project, and test locally++ Create a single project to host your production instance. Test any changes locally, then run the migrations against your hosted production project.++You can also combine both strategies to perform both local and staging tests.## Feedback-Supabase branching is a new and exciting new part of the Supabase development ecosystem. We’re monitoring its success and open to any feedback.+Supabase branching is a new and exciting new part of the Supabase development ecosystem. We're monitoring its success and open to any feedback.You can join the [conversation over in GitHub discussions](https://github.com/orgs/supabase/discussions/18937).