GitOps with Feature Branch Workflow
Overview
In a Git feature branch workflow, all feature development takes place in a dedicated branch instead of main branch. When the feature development finishes, it will be merged into the main branch. This articles shows you a typical Bytebase setup for teams using one main
branch and one dev
(feature) branch.
Prerequisites
- You have two branches:
- One
main
branch corresponds to theprod
envrionment, and it has adb_prod
database. - One
dev
branch for the feature work corresponds to thedev
environment, and it has adb_dev
database.
- You installed Bytebase and have Workspace Admin role.
The Procedure
Step 1 - Configure the workspace
- Go to Settings > Workspace > Version Control to add a VCS provider.
- Click Environments and create two environments
Dev
andProd
. You can configure approval policy as require or skip manual approval. - Click Instances > Add Instance to add instances where
db_prod
anddb_dev
are located.
Step 2 - Create Dev Project
- Click Projects > New Project and enter
Dev Project
in Project Name. - In
Dev Project
, click Transfer in DB and choosedb_dev
database. - Click Version Control on the project tab bar, and choose GitOps workflow and enable GitOps workflow.
Step 3 - Create Prod Project
- Repeat Step 2, but with Prod instead of Dev, e.g.
Prod Project
instead ofDev Project
.
Step 4 - Create SQL migration file
- Name and organize SQL migration files like this.
Final Setup
The final setup looks like this:
With this setup,
-
When a SQL migration file is committed to the
dev
branch, Bytebase will create an issue inDev Project
and apply that migration file todb_dev
. -
When you merge the
dev
branch to themain
branch with one or more SQL migration file commits, Bytebase will create a separate issue for each SQL migration file inProd Project
and apply the corresponding migration change todb_prod
.