Skip to main content
SDL validation runs automatically during pull/merge requests to catch syntax and convention violations before merge.
Work in Progress: SDL SQL Review currently supports basic syntax checks and pre-defined SDL validation rules. Custom SQL Review rules configured in the Bytebase SQL Review Policy feature are not yet supported for SDL workflows, but this capability is actively under development.

What Gets Validated

SDL-specific checks (Current):
  • Schema qualification on all objects
  • Table-level constraint placement
  • Constraint naming requirements
  • Foreign key type matching
  • Cross-file integrity validation
  • Unsupported statement detection
  • SQL syntax validation
Coming Soon:
  • Custom SQL Review Policy rules from Bytebase
  • Team-specific naming conventions
  • Custom validation rules

SQL Review Policy

Learn about SQL Review Policy (migration-based workflow)

CI/CD Integration

Enable declarative mode by adding the --declarative flag:
  • GitHub Actions
  • GitLab CI
  • Azure DevOps
# .github/workflows/sql-review.yml
name: SDL Review
on:
  pull_request:
    paths:
      - 'schema/**'

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

      - name: SDL Validation
        uses: bytebase/sql-review-action@v1
        with:
          bytebase-url: ${{ secrets.BYTEBASE_URL }}
          bytebase-token: ${{ secrets.BYTEBASE_SERVICE_ACCOUNT_TOKEN }}
          file-pattern: 'schema/**/*.sql'
          declarative: true  # Enable SDL mode

GitHub Tutorial

Common Validation Errors

Error: Table 'users' must include schema nameFix: Add schema prefix to all objects
-- Change: CREATE TABLE users
-- To: CREATE TABLE public.users
Error: PRIMARY KEY must be table-level constraintFix: Move constraint to table level
-- Change:
id INTEGER PRIMARY KEY

-- To:
id INTEGER,
CONSTRAINT users_pkey PRIMARY KEY (id)
Error: All constraints must have explicit namesFix: Add CONSTRAINT keyword with name
-- Change: UNIQUE (email)
-- To: CONSTRAINT users_email_key UNIQUE (email)
Error: Foreign key column 'user_id' (INTEGER) references 'users.id' (BIGINT)Fix: Align column types
-- Ensure both are same type
user_id BIGINT  -- Match users.id type

Next Steps