Bytebase is a database DevSecOps platform designed for developers, security, DBA, and platform engineering teams. While it offers an intuitive GUI for managing database schema changes and access control, some teams may want to integrate Bytebase into their existing DevOps platforms using the Bytebase API.
This tutorial will guide you through configuring SQL review rules using the Bytebase API. This approach allows you to manage SQL review rules as code within your repository, enabling DBAs or platform engineering teams to apply them to Bytebase as needed. The tutorial repository is at https://github.com/bytebase/example-api/tree/main/sql-review.
This is one of the tutorial series of SQL Review:
Make sure your Docker daemon is running. Copy and paste the commands to start Bytebase.
Bytebase is now running via Docker, and you can access it via localhost:8080
. Register the first admin account which will be granted Workspace Admin
.
Log in as Workspace Admin
, and go to IAM & Admin > Users & Groups. Click + Add User, fill in with api-sample
, choose the Workspace DBA
role sufficient for this tutorial and click Confirm.
Find the newly created service account and Copy Service Key. We will use this token to authenticate the API calls.
Go to Bytebase API Example repo and clone it.
Navigate to the sql-review
subfolder and follow the instructions in the README.md
file of the example code repository to execute the scripts.
Replace bytebase_url
, bytebase_account
, and bytebase_password
in the commands below with your own values, then run them to obtain a bytebase_token
in your terminal.
Continue following the README.md
to run the scripts.
In the Bytebase console, navigate to CI/CD > SQL Review to see the applied SQL review rules. You may click Edit to change the rules.
We’ll apply these SQL review rules to environments
or projects
. Project-level rules take precedence over environment-level rules.
Run these command in ‘README.md’ of the repo to apply the SQL review rules to environments.
Continue with the README.md
to apply the SQL review rules to projects.
On the CI/CD > SQL Review page, you will see the SQL review rules are applied to environments and projects.
Go to Environments page, click Test environment to see the applied SQL review rules.
Go to Sample Project
page, click Setting on the left sidebar to see the applied the SQL review rules.
To detach SQL review policies from environments, use the following commands:
Similarly as to detach from projects:
To delete the SQL review rules, use the following commands:
Congratulations! You can now codify SQL review rules using the Bytebase API, in addition to the Bytebase GUI, making SQL review policy as code a reality.
Bytebase is a database DevSecOps platform designed for developers, security, DBA, and platform engineering teams. While it offers an intuitive GUI for managing database schema changes and access control, some teams may want to integrate Bytebase into their existing DevOps platforms using the Bytebase API.
This tutorial will guide you through configuring SQL review rules using the Bytebase API. This approach allows you to manage SQL review rules as code within your repository, enabling DBAs or platform engineering teams to apply them to Bytebase as needed. The tutorial repository is at https://github.com/bytebase/example-api/tree/main/sql-review.
This is one of the tutorial series of SQL Review:
Make sure your Docker daemon is running. Copy and paste the commands to start Bytebase.
Bytebase is now running via Docker, and you can access it via localhost:8080
. Register the first admin account which will be granted Workspace Admin
.
Log in as Workspace Admin
, and go to IAM & Admin > Users & Groups. Click + Add User, fill in with api-sample
, choose the Workspace DBA
role sufficient for this tutorial and click Confirm.
Find the newly created service account and Copy Service Key. We will use this token to authenticate the API calls.
Go to Bytebase API Example repo and clone it.
Navigate to the sql-review
subfolder and follow the instructions in the README.md
file of the example code repository to execute the scripts.
Replace bytebase_url
, bytebase_account
, and bytebase_password
in the commands below with your own values, then run them to obtain a bytebase_token
in your terminal.
Continue following the README.md
to run the scripts.
In the Bytebase console, navigate to CI/CD > SQL Review to see the applied SQL review rules. You may click Edit to change the rules.
We’ll apply these SQL review rules to environments
or projects
. Project-level rules take precedence over environment-level rules.
Run these command in ‘README.md’ of the repo to apply the SQL review rules to environments.
Continue with the README.md
to apply the SQL review rules to projects.
On the CI/CD > SQL Review page, you will see the SQL review rules are applied to environments and projects.
Go to Environments page, click Test environment to see the applied SQL review rules.
Go to Sample Project
page, click Setting on the left sidebar to see the applied the SQL review rules.
To detach SQL review policies from environments, use the following commands:
Similarly as to detach from projects:
To delete the SQL review rules, use the following commands:
Congratulations! You can now codify SQL review rules using the Bytebase API, in addition to the Bytebase GUI, making SQL review policy as code a reality.