Databases 7 min read

Implementing Database GitOps with Bytebase: A Step‑by‑Step Guide

This article walks through setting up a local MySQL cluster, configuring Ngrok, deploying Bytebase via Docker, enabling GitOps integration with GitHub, and managing SQL schema changes through automated pull‑request workflows, providing code snippets and detailed screenshots for each step.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Implementing Database GitOps with Bytebase: A Step‑by‑Step Guide

The author shares a practical experience of using Bytebase GitOps to manage SQL changes, automatically creating Bytebase tickets when SQL files are added or modified and storing the latest database schema in a GitHub repository.

1. Environment preparation – a local MySQL cluster, a GitHub account with a public repository, Docker with Bytebase installed, and Ngrok for reverse‑proxying GitHub webhooks.

2. Obtain Ngrok URL – download Ngrok, configure the auth token, and run ngrok http 5678 to expose Bytebase on a public URL.

ngrok config add-authtoken 1o6O3ur1sBElTPLLEeG9uTAE7aw_JD3tGF4KCMBHbneog3Tz

3. Deploy Bytebase – use the following docker-compose.yaml (note the --external-url argument pointing to the Ngrok URL):

version: "3.7"

services:
  bytebase:
    image: bytebase/bytebase:1.12.1
    init: true
    container_name: bytebase
    restart: always
    ports:
      - 5678:5678
    command: ["--data", "/var/opt/bytebase", "--port", "5678", "--external-url", "https://262d-2409-8a00-242d-ab60-f4b8-70a1-71e3-1c2b.ap.ngrok.io"]

  employee-prod:
    image: bytebase/sample-database:mysql-employee-small
    ports:
      - 3306:3306

  employee-test:
    image: bytebase/sample-database:mysql-employee-small
    ports:
      - 3307:3306

Start the containers with docker-compose up -d and access Bytebase at the Ngrok URL.

4. Configure GitOps in Bytebase – navigate to Settings → GitOps, create a GitHub OAuth App to obtain the Application ID and Secret, and fill them into Bytebase.

5. Enable GitOps for a project – in the project’s GitOps settings, select GitHub as the provider, link the repository, and define the directory and file‑path template (e.g., /bytebase/{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESC}}.sql ).

6. Submit SQL change – add a SQL file such as bytebase/Test/employee##202302071000##ddl##create_table.sql with content:

CREATE TABLE subject (
  id BIGINT NOT NULL,
  course VARCHAR(255)
);

Push the change; Bytebase captures the Git push event, creates an issue ticket, and displays the executed SQL and migration details.

7. Subsequent changes – repeat the process to modify existing tables (e.g., adding columns to subject ), and Bytebase will generate new tickets and update the latest schema in the repository.

By following these steps, developers can achieve automated, version‑controlled database schema management using Bytebase, Docker, Ngrok, and GitHub.

DockerSQLGitOpsNgrokDatabase CI/CDBytebase
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.