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.
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 Settings → General → AI 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
Create a Markdown file with your SQL review standards. We recommend placing it in .bytebase/sql-review.md:
Copy
Ask AI
# .bytebase/sql-review.md# SQL Review Standards## 1. Table Naming Convention- All table names must be in snake_case- Table names should be plural nouns (e.g., users, orders, products)- Avoid abbreviations unless commonly understood## 2. Column Standards- Every table must have a created_at timestamp column- Every table must have an updated_at timestamp column- Primary key columns should be named 'id'## 3. Index Requirements- Foreign key columns must have indexes- Columns used in WHERE clauses frequently should be indexed## 4. Comment Requirements- All tables must have descriptive comments- Complex columns should have comments explaining their purpose## 5. Type Consistency- Use TEXT instead of VARCHAR for string columns- Use TIMESTAMP for datetime values- Use BIGINT for auto-incrementing primary keys
When AI detects violations, you’ll see detailed feedback in your PR/MR:
Copy
Ask AI
❌ AI-powered validation errors found:File: schemas/public/tables/users.sqlRule: Table Naming ConventionMessage: Table name 'User' should be plural. Consider renaming to 'users'.Line: 1File: schemas/public/tables/products.sqlRule: Column StandardsMessage: Table 'products' is missing required 'created_at' timestamp column.Line: 1File: schemas/public/tables/orders.sqlRule: Index RequirementsMessage: Foreign key column 'user_id' should have an index for better query performance.Line: 5
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
Copy
Ask AI
## Naming Conventions- Tables: plural, snake_case- Columns: singular, snake_case## Type Standards- Timestamps: use TIMESTAMP NOT NULL- Text fields: use TEXT not VARCHAR
Document the “Why”: Explain the rationale behind each standard
Copy
Ask AI
## Primary Key TypeUse BIGINT for primary keys (not INTEGER) to prevent ID exhaustionin high-volume tables and support future growth.
Start Small, Iterate: Begin with a few critical standards and expand based on team needs
Version Control Standards: Commit .bytebase/sql-review.md to your repository alongside schema files for team collaboration