- SQL Review with Bytebase GUI (this one)
- SQL Review with CI (integrated with Database GitOps workflow):Add commentMore actions
- SQL Review with Bytebase API
- Codify SQL Review Policies with Bytebase API
Prerequisites
Make sure you have Docker installed, and if you don’t have important existing Bytebase data locally, you can start over from scratch byrm -rf ~/.bytebase/data
.
Start Bytebase with sample data
-
Ensure Docker is running, then start the Bytebase container:
-
Open Bytebase in localhost:8080, fill in the fields and click Create admin account. You’ll be redirected to Workspace.
-
During workspace setup, choose the built-in sample data.
Configure SQL Review Policies
- Navigate to CI/CD > SQL Review in the left menu. Click + New SQL Review to create a new SQL review.
-
Choose
Sample Template
which has 20 enabled rules and click Confirm and add. Attach the SQL review to EnvironmentProd
and click Confirm. -
You’ll see the SQL review is created. Note that there’s a warning sign for the
NOT NULL
rule.
Trigger SQL Review
-
Go to
Sample Project
, navigate to CI/CD > Plans and click + New Plan. -
Select Schema Migration (DDL) as the change type.
-
Select
hr_prod
database as the target since the default SQL Review policy is attached to theProd
environment. Click Confirm to proceed. You can use the Schema Editor to visually design the schema, here we’ll intentionally uncheck Not Null fornickname
column. -
The plan will be in
Draft
status. SQL Review will run automatically, and you’ll see violations against our defined rules marked in orange aswarning
. -
You may resolve this by editing the SQL to add
NOT NULL
constraints. Click Save to update the plan. The SQL Review checks will run again and should now pass.