Deploy Schema Migration with Bytebase API
Bytebase - Database CI/CD and Security at Scale
Leading open source database DevSecOps solution for Developer, Security, DBA, and Platform Engineering team.
Hi and welcome to Database DevOps Academy #25!
Each week, we share Database DevOps insights and best practices for modern engineering organizations. If you enjoy this newsletter, we ask you to subscribe and share. ??
In this Issue #25, we are exploring how to deploy database schema migrations through Bytebase API. Enjoy!
Bytebase is a database DevOps and CI/CD Tool for Developer, DBA and Platform Engineering teams. It provides an intuitive GUI to manage database schema changes. On the other hand, for some teams, they may want to integrate Bytebase into their existing DevOps platform. This requires calling 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.
The API example repository is at https://github.com/bytebase/api-example
Prerequisites
Start Bytebase and prepare the accounts
docker run --init \
--name bytebase \
--restart always \
--publish 5678:8080 \
--health-cmd "curl --fail https://localhost:8080/healthz || exit 1" \
--health-interval 5m \
--health-timeout 10s \
--volume ~/.bytebase/data:/var/opt/bytebase \
bytebase/bytebase:2.12.0 \
--data /var/opt/bytebase \
--port 8080
领英推荐
Create a schema change in Bytebase Console
Let's first review how to create a schema change from console directly.
CREATE TABLE test_from_console ( id integer NOT NULL );
Create a schema change via Bytebase API
Below is an example app demonstrating the following APIs:
pnpm i && pnpm dev
CREATE TABLE test_from_api ( id integer NOT NULL );
Summary
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.