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
- 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
- Write Your Standards: Document your team’s SQL conventions in natural language (supports any language)
- AI Validates: Bytebase AI analyzes your schema files against your documented standards
- Get Feedback: Receive specific, actionable feedback on any violations with exact file and line references
Setup Requirements
Step 1: Enable AI in Bytebase (One-time setup)- Navigate to Settings → General → AI Assistant
- Enable AI and choose your provider (OpenAI, Azure OpenAI, Gemini, or Claude)
- Enter your API credentials and test the connection
- Create
.bytebase/sql-review.mdin your repository - Write your team’s SQL standards in natural language - no special syntax required
- Add the
--custom-rulesflag 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
-
Be Specific and Actionable: Clear, specific standards produce better AI analysis
- ✅ “Primary key columns must be named ‘id’”
- ❌ “Use good naming conventions”
-
Organize by Category: Group related standards for clarity
-
Document the “Why”: Explain the rationale behind each standard
- Start Small, Iterate: Begin with a few critical standards and expand based on team needs
-
Version Control Standards: Commit
.bytebase/sql-review.mdto 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
- GitHub Actions
- GitLab CI
- Azure DevOps
- Command Line
Basic SDL Validation
Basic SDL Validation
With Your Team's Standards
With Your Team's Standards
Prerequisites: AI must be enabled in Bytebase Settings → AI Assistant
GitHub Tutorial
Common Validation Errors
Missing schema qualification
Missing schema qualification
Error:
Table 'users' must include schema nameFix: Add schema prefix to all objectsColumn-level constraint
Column-level constraint
Error:
PRIMARY KEY must be table-level constraintFix: Move constraint to table levelUnnamed constraint
Unnamed constraint
Error:
All constraints must have explicit namesFix: Add CONSTRAINT keyword with nameType mismatch in foreign key
Type mismatch in foreign key
Error:
Foreign key column 'user_id' (INTEGER) references 'users.id' (BIGINT)Fix: Align column types
