You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SDL validation runs automatically during pull/merge requests to catch syntax and convention violations before merge.
6
6
7
-
<Warning>
8
-
**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.
9
-
</Warning>
10
-
11
7
## What Gets Validated
12
8
13
-
**SDL-specific checks (Current):**
9
+
**SDL-specific checks:**
14
10
- Schema qualification on all objects
15
11
- Table-level constraint placement
16
12
- Constraint naming requirements
@@ -19,87 +15,319 @@ SDL validation runs automatically during pull/merge requests to catch syntax and
19
15
- Unsupported statement detection
20
16
- SQL syntax validation
21
17
22
-
**Coming Soon:**
23
-
- Custom SQL Review Policy rules from Bytebase
24
-
- Team-specific naming conventions
25
-
- Custom validation rules
18
+
**AI-powered validation with your team's standards (Optional):**
19
+
- Define standards in natural language (any language)
20
+
- Enforce team-specific conventions
21
+
- Get context-aware recommendations
22
+
- Validate naming conventions and best practices
23
+
24
+
## AI-Powered Validation with Your Standards
25
+
26
+
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.
27
+
28
+
### How It Works
29
+
30
+
1.**Write Your Standards**: Document your team's SQL conventions in natural language (supports any language)
31
+
2.**AI Validates**: Bytebase AI analyzes your schema files against your documented standards
32
+
3.**Get Feedback**: Receive specific, actionable feedback on any violations with exact file and line references
33
+
34
+
### Setup Requirements
35
+
36
+
<Warning>
37
+
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.
38
+
</Warning>
39
+
40
+
**Step 1: Enable AI in Bytebase** (One-time setup)
41
+
- Navigate to **Settings** → **General** → **AI Assistant**
42
+
- Enable AI and choose your provider (OpenAI, Azure OpenAI, Gemini, or Claude)
43
+
- Enter your API credentials and test the connection
44
+
45
+
**Step 2: Document Your Standards**
46
+
- Create `.bytebase/sql-review.md` in your repository
47
+
- Write your team's SQL standards in natural language - no special syntax required
48
+
49
+
**Step 3: Update Your CI/CD Pipeline**
50
+
- Add the `--custom-rules` flag pointing to your standards file
51
+
- See platform-specific examples in the [CI/CD Integration](#cicd-integration) section
52
+
53
+
### Example: SQL Review Standards
54
+
55
+
Create a Markdown file with your SQL review standards. We recommend placing it in `.bytebase/sql-review.md`:
56
+
57
+
```markdown
58
+
# .bytebase/sql-review.md
59
+
# SQL Review Standards
60
+
61
+
## 1. Table Naming Convention
62
+
- All table names must be in snake_case
63
+
- Table names should be plural nouns (e.g., users, orders, products)
64
+
- Avoid abbreviations unless commonly understood
65
+
66
+
## 2. Column Standards
67
+
- Every table must have a created_at timestamp column
68
+
- Every table must have an updated_at timestamp column
69
+
- Primary key columns should be named 'id'
70
+
71
+
## 3. Index Requirements
72
+
- Foreign key columns must have indexes
73
+
- Columns used in WHERE clauses frequently should be indexed
74
+
75
+
## 4. Comment Requirements
76
+
- All tables must have descriptive comments
77
+
- Complex columns should have comments explaining their purpose
78
+
79
+
## 5. Type Consistency
80
+
- Use TEXT instead of VARCHAR for string columns
81
+
- Use TIMESTAMP for datetime values
82
+
- Use BIGINT for auto-incrementing primary keys
83
+
```
84
+
85
+
### AI Validation Output
86
+
87
+
When AI detects violations, you'll see detailed feedback in your PR/MR:
88
+
89
+
```
90
+
❌ AI-powered validation errors found:
91
+
92
+
File: schemas/public/tables/users.sql
93
+
Rule: Table Naming Convention
94
+
Message: Table name 'User' should be plural. Consider renaming to 'users'.
95
+
Line: 1
96
+
97
+
File: schemas/public/tables/products.sql
98
+
Rule: Column Standards
99
+
Message: Table 'products' is missing required 'created_at' timestamp column.
0 commit comments