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.
In this tutorial, you will begin by creating a schema change within the Bytebase console. Then, you will proceed to run an external sample application that utilizes the API to create a similar change.
By following the step-by-step instructions provided, you will have the opportunity to explore and experiment with the Bytebase API. This will give you a practical understanding of how to incorporate it into your own application.
https://github.com/bytebase/example-api/tree/main/issue-creation
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.
Let’s first review how to create a schema change from console directly.
Stay in Bytebase console, go to Sample Project
. Click the checkbox for hr_prod
and click Edit Schema.
Switch Raw SQL, paste the following SQL statement and click Preview issue.
Click Create, after the automatic checks are done, it’ll automatically roll out the change. The issue will become Done.
Below is an example app demonstrating the following APIs:
Go to Bytebase API Example repo and clone it.
Copy env-template.local
to .env.local
.Update the variables.
NEXT_PUBLIC_BB_URL
: http://localhost:8080
NEXT_PUBLIC_BB_SERVICE_ACCOUNT
: api-example
NEXT_PUBLIC_BB_SERVICE_KEY
: service key copied in Step 2Run the following commands to start the sample application.
Open the application in your browser, you’ll see the following page.
Choose Sample Project
, then hr_prod
, input the following SQL and click Create New Issue.
The issue will be created and you’ll see the following page.
Click the link View issue xxx in Bytebase[OPEN]
to see the issue in Bytebase Console. You’ll notice the issue rolls out automatically and becomes Done
.
Go back to the sample application, and click Refresh status. You’ll see the status has changed from [OPEN] to [DONE].
For additional information about the example application, refer to the README in its corresponding GitHub repository.
Congratulations! You’ve successfully created a schema change via Bytebase API. In similar ways, you could integrate Bytebase API into your existing DevOps platform to automate your schema change process, and benefit Bytebase features such as SQL Review, Custom Approval and Schema Drift Detection.
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.
In this tutorial, you will begin by creating a schema change within the Bytebase console. Then, you will proceed to run an external sample application that utilizes the API to create a similar change.
By following the step-by-step instructions provided, you will have the opportunity to explore and experiment with the Bytebase API. This will give you a practical understanding of how to incorporate it into your own application.
https://github.com/bytebase/example-api/tree/main/issue-creation
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.
Let’s first review how to create a schema change from console directly.
Stay in Bytebase console, go to Sample Project
. Click the checkbox for hr_prod
and click Edit Schema.
Switch Raw SQL, paste the following SQL statement and click Preview issue.
Click Create, after the automatic checks are done, it’ll automatically roll out the change. The issue will become Done.
Below is an example app demonstrating the following APIs:
Go to Bytebase API Example repo and clone it.
Copy env-template.local
to .env.local
.Update the variables.
NEXT_PUBLIC_BB_URL
: http://localhost:8080
NEXT_PUBLIC_BB_SERVICE_ACCOUNT
: api-example
NEXT_PUBLIC_BB_SERVICE_KEY
: service key copied in Step 2Run the following commands to start the sample application.
Open the application in your browser, you’ll see the following page.
Choose Sample Project
, then hr_prod
, input the following SQL and click Create New Issue.
The issue will be created and you’ll see the following page.
Click the link View issue xxx in Bytebase[OPEN]
to see the issue in Bytebase Console. You’ll notice the issue rolls out automatically and becomes Done
.
Go back to the sample application, and click Refresh status. You’ll see the status has changed from [OPEN] to [DONE].
For additional information about the example application, refer to the README in its corresponding GitHub repository.
Congratulations! You’ve successfully created a schema change via Bytebase API. In similar ways, you could integrate Bytebase API into your existing DevOps platform to automate your schema change process, and benefit Bytebase features such as SQL Review, Custom Approval and Schema Drift Detection.