Skip to main content
After PR/MR merge, Bytebase creates a release, compares the desired state with current database state, generates migration DDL, and deploys.

How SDL Release Works

  1. State Comparison - Bytebase compares your SDL files with current database schema
  2. DDL Generation - Automatically generates ALTER/DROP statements using topological sort
  3. Migration Execution - Applies generated DDL to reach desired state
  4. Revision Tracking - Records new version for future comparisons

CI/CD Integration

Add --declarative flag to enable SDL mode:
  • GitHub Actions
  • GitLab CI
  • Azure DevOps
# .github/workflows/release.yml
name: SDL Release
on:
  push:
    branches: [main]
    paths:
      - 'schema/**'

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Deploy SDL
        uses: bytebase/sql-review-action@v1
        with:
          command: rollout
          bytebase-url: ${{ secrets.BYTEBASE_URL }}
          bytebase-token: ${{ secrets.BYTEBASE_SERVICE_ACCOUNT_TOKEN }}
          file-pattern: 'schema/**/*.sql'
          project: projects/my-project
          targets: instances/prod/databases/mydb
          declarative: true

Version Management

SDL automatically generates versions using timestamp format YYYYMMDD.HHMMSS:
Release 2025-01-15 10:30:00 → Version: 20250115.103000
Release 2025-01-20 14:15:00 → Version: 20250120.141500
All files in a release share the same version. Bytebase compares this version with the latest revision to determine if deployment is needed.

Migration Generation Example

Current Database:
CREATE TABLE public.users (
    id INTEGER PRIMARY KEY,
    username TEXT NOT NULL
);
New SDL:
CREATE TABLE public.users (
    id INTEGER,
    username TEXT NOT NULL,
    email TEXT NOT NULL,
    CONSTRAINT users_pkey PRIMARY KEY (id),
    CONSTRAINT users_email_key UNIQUE (email)
);

CREATE INDEX idx_users_email ON public.users(email);
Generated Migration:
-- Bytebase automatically generates:
ALTER TABLE public.users ADD COLUMN email TEXT NOT NULL;
ALTER TABLE public.users ADD CONSTRAINT users_email_key UNIQUE (email);
CREATE INDEX idx_users_email ON public.users(email);

Next Steps