Skip to content

Commit 0f8e30a

Browse files
authored
feat: doc update for gitops and SDL (#925)
1 parent 7ad199f commit 0f8e30a

27 files changed

+4159
-142
lines changed

mintlify/changelog/bytebase-1-8-0.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import InstallUpgrade from '/snippets/install/install-upgrade.mdx';
1111

1212
- Support syncing schema for MySQL.
1313
- Support approving issues via Lark (Feishu).
14-
- Support [SQL Review CI in the GitOps workflow](/gitops/sql-review-ci).
14+
- Support [SQL Review CI in the GitOps workflow](/gitops/migration-based-workflow/sql-review-ci).
1515
- DBAs and workspace admins can run SQL statements in Admin mode from the SQL Editor.
1616
- Support altering multiple databases on tenant mode.
1717

mintlify/docs.json

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,47 @@
130130
"pages": [
131131
"gitops/overview",
132132
"gitops/installation",
133-
"gitops/develop",
134-
"gitops/sql-review-ci",
135-
"gitops/release"
133+
{
134+
"group": "Migration-Based Workflow",
135+
"pages": [
136+
"gitops/migration-based-workflow/overview",
137+
"gitops/migration-based-workflow/develop",
138+
"gitops/migration-based-workflow/sql-review-ci",
139+
"gitops/migration-based-workflow/release",
140+
"gitops/migration-based-workflow/limitations"
141+
]
142+
},
143+
{
144+
"group": "State-Based Workflow (SDL)",
145+
"pages": [
146+
"gitops/state-based-workflow/overview",
147+
"gitops/state-based-workflow/develop",
148+
"gitops/state-based-workflow/sql-review-ci",
149+
"gitops/state-based-workflow/release",
150+
"gitops/state-based-workflow/limitations"
151+
]
152+
},
153+
{
154+
"group": "Best Practices",
155+
"pages": [
156+
"gitops/best-practices/overview",
157+
"gitops/best-practices/file-organization",
158+
"gitops/best-practices/migration-guidelines",
159+
"gitops/best-practices/git-and-cicd",
160+
"gitops/best-practices/sql-review-and-security",
161+
"gitops/best-practices/performance-and-drift"
162+
]
163+
},
164+
{
165+
"group": "Troubleshooting",
166+
"pages": [
167+
"gitops/troubleshooting/overview",
168+
"gitops/troubleshooting/release-and-plan",
169+
"gitops/troubleshooting/rollout",
170+
"gitops/troubleshooting/sdl-issues",
171+
"gitops/troubleshooting/cicd-issues"
172+
]
173+
}
136174
]
137175
},
138176
{
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
title: File Organization
3+
---
4+
5+
Proper file organization is crucial for maintainable GitOps workflows. This guide covers repository structures and directory layouts that scale with your team.
6+
7+
## Repository Structure
8+
9+
### Monorepo Approach
10+
11+
Database migrations alongside application code:
12+
13+
```
14+
my-app/
15+
├── src/ # Application code
16+
├── migrations/ # Database migrations
17+
│ ├── versioned/
18+
│ │ ├── 001__init.sql
19+
│ │ └── 002__add_users.sql
20+
│ └── schema/
21+
│ └── public.sql # SDL if using declarative
22+
├── .github/workflows/
23+
│ └── bytebase-gitops.yml # CI/CD integration
24+
└── README.md
25+
```
26+
27+
**Benefits:**
28+
- Migrations versioned with application code
29+
- Atomic commits for schema + code changes
30+
- Single source of truth
31+
32+
**Best for:**
33+
- Small to medium teams
34+
- Tight schema-code coupling
35+
- Monolithic or modular monolith architectures
36+
37+
### Separate Repository
38+
39+
Dedicated database repository:
40+
41+
```
42+
database-schemas/
43+
├── app-db/
44+
│ ├── migrations/
45+
│ └── schema/
46+
├── analytics-db/
47+
│ └── migrations/
48+
└── .gitlab-ci.yml
49+
```
50+
51+
**Benefits:**
52+
- Separation of concerns
53+
- Independent deployment cycles
54+
- Multiple teams/databases
55+
56+
**Best for:**
57+
- Larger organizations
58+
- Dedicated database teams
59+
- Microservices with shared databases
60+
61+
<Tip>
62+
Choose based on your team structure. Co-located migrations work well for small teams with tight schema-code coupling. Separate repos fit larger organizations with dedicated database teams.
63+
</Tip>
64+
65+
## Directory Layout
66+
67+
### For Migration-Based Workflow
68+
69+
**Option 1: Organized by Category**
70+
71+
```
72+
migrations/
73+
├── baseline/
74+
│ └── 000__initial_schema.sql # Initial baseline
75+
├── features/
76+
│ ├── 001__users.sql
77+
│ ├── 002__products.sql
78+
│ └── 003__orders.sql
79+
└── hotfixes/
80+
└── 004__fix_index.sql
81+
```
82+
83+
**Benefits:**
84+
- Clear organization by purpose
85+
- Easy to navigate
86+
- Separates routine changes from emergencies
87+
88+
**Option 2: Flat Structure**
89+
90+
```
91+
migrations/
92+
├── 001__initial_schema.sql
93+
├── 002__add_users.sql
94+
├── 003__add_products_dml.sql
95+
└── 004__add_indexes.sql
96+
```
97+
98+
**Benefits:**
99+
- Simple and straightforward
100+
- Chronological ordering
101+
- Easy to understand
102+
103+
### For State-Based Workflow (SDL)
104+
105+
**Option 1: Organized by Schema**
106+
107+
```
108+
schema/
109+
├── public.sql # Main schema
110+
├── analytics.sql # Analytics schema
111+
└── internal.sql # Internal schema
112+
```
113+
114+
**Benefits:**
115+
- Clear schema separation
116+
- Matches database structure
117+
- Easy to find objects
118+
119+
**Option 2: Split by Object Type**
120+
121+
```
122+
schema/
123+
├── 01_tables.sql
124+
├── 02_indexes.sql
125+
├── 03_views.sql
126+
├── 04_functions.sql
127+
└── 05_sequences.sql
128+
```
129+
130+
**Benefits:**
131+
- Organized by DDL type
132+
- Predictable file structure
133+
- Clear dependencies (tables before indexes)
134+
135+
### Hybrid Approach
136+
137+
Combine both workflows for different purposes:
138+
139+
```
140+
database/
141+
├── schema/ # SDL for structure (DDL)
142+
│ ├── public.sql
143+
│ └── analytics.sql
144+
├── migrations/ # Migrations for data (DML)
145+
│ ├── 001__seed_roles_dml.sql
146+
│ └── 002__migrate_users_dml.sql
147+
└── .github/workflows/
148+
├── schema-cicd.yml # SDL pipeline
149+
└── data-cicd.yml # Migration pipeline
150+
```
151+
152+
**Best for:**
153+
- Teams wanting declarative schema management
154+
- Projects requiring data migrations
155+
- Gradual migration from versioned to SDL
156+
157+
## Documentation Structure
158+
159+
Maintain supporting documentation alongside migrations:
160+
161+
```
162+
database/
163+
├── migrations/
164+
├── schema/
165+
├── docs/
166+
│ ├── CHANGELOG.md # Schema changelog
167+
│ ├── DEPENDENCIES.md # Schema-app dependencies
168+
│ └── ROLLBACK_PLAN.md # Rollback procedures
169+
└── test-data/
170+
└── seed.sql # Test data for development
171+
```
172+
173+
---
174+
175+
## Next Steps
176+
177+
<CardGroup cols={2}>
178+
<Card title="Migration Guidelines" icon="file-code" href="/gitops/best-practices/migration-guidelines">
179+
Learn version numbering and file best practices
180+
</Card>
181+
182+
<Card title="Git and CI/CD" icon="git-branch" href="/gitops/best-practices/git-and-cicd">
183+
Set up branching strategies and pipelines
184+
</Card>
185+
</CardGroup>

0 commit comments

Comments
 (0)