Skip to main content
SDL validation runs automatically during pull/merge requests to catch syntax and convention violations before merge.

What Gets Validated

SDL-specific checks:
  • 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
AI-powered validation with your team’s standards (Optional):
  • Define standards in natural language (any language)
  • Enforce team-specific conventions
  • Get context-aware recommendations
  • Validate naming conventions and best practices

AI-Powered Validation with Your Standards

Enhance SDL validation by teaching AI your team’s SQL standards using natural language. Define your project’s conventions, naming rules, and best practices in any language - AI will validate your schema against them.

How It Works

  1. Write Your Standards: Document your team’s SQL conventions in natural language (supports any language)
  2. AI Validates: Bytebase AI analyzes your schema files against your documented standards
  3. Get Feedback: Receive specific, actionable feedback on any violations with exact file and line references

Setup Requirements

AI must be enabled and configured in your Bytebase instance to use this feature. Without AI setup, your standards file will be ignored during validation.
Step 1: Enable AI in Bytebase (One-time setup)
  • Navigate to SettingsGeneralAI Assistant
  • Enable AI and choose your provider (OpenAI, Azure OpenAI, Gemini, or Claude)
  • Enter your API credentials and test the connection
Step 2: Document Your Standards
  • Create .bytebase/sql-review.md in your repository
  • Write your team’s SQL standards in natural language - no special syntax required
Step 3: Update Your CI/CD Pipeline
  • Add the --custom-rules flag pointing to your standards file
  • See platform-specific examples in the CI/CD Integration section

Example: SQL Review Standards

Create a Markdown file with your SQL review standards. We recommend placing it in .bytebase/sql-review.md:

AI Validation Output

When AI detects violations, you’ll see detailed feedback in your PR/MR:

Best Practices for SQL Review Standards

  1. Be Specific and Actionable: Clear, specific standards produce better AI analysis
    • ✅ “Primary key columns must be named ‘id’”
    • ❌ “Use good naming conventions”
  2. Organize by Category: Group related standards for clarity
  3. Document the “Why”: Explain the rationale behind each standard
  4. Start Small, Iterate: Begin with a few critical standards and expand based on team needs
  5. Version Control Standards: Commit .bytebase/sql-review.md to your repository alongside schema files for team collaboration

CI/CD Integration

Configure SDL validation in your CI/CD pipeline. Choose between:
  • Basic SDL Validation: Built-in checks for syntax, naming, and structure
  • With Your Team’s Standards: AI validates against your custom standards in .bytebase/sql-review.md
Use a compatible bytebase-action image. For Bytebase Cloud, use bytebase/bytebase-action:cloud. For self-hosted Bytebase, replace :cloud with your Bytebase server version, for example :3.14.0.

With Your Team's Standards

Prerequisites: AI must be enabled in Bytebase Settings → AI Assistant

GitHub Tutorial

Common Validation Errors

Error: Table 'users' must include schema nameFix: Add schema prefix to all objects
Error: PRIMARY KEY must be table-level constraintFix: Move constraint to table level
Error: All constraints must have explicit namesFix: Add CONSTRAINT keyword with name
Error: Foreign key column 'user_id' (INTEGER) references 'users.id' (BIGINT)Fix: Align column types

Next Steps

Release

Deploy SDL changes after validation approval

SQL Review Rules

Explore all available SQL review rules