MySQL Migration & Quality Upgrade Log
This document records the remediation and quality upgrade process performed on the MySQL documentation (Modules 10–18) after its initial migration from Notion. It serves as a comprehensive reference for future AI agents on how to structure, rewrite, and verify technical documentation improvements.
1. Environment & Paths
Key Paths
| Item | Path |
|---|---|
| MySQL docs root | /opt/docker-data/apps/docusaurus/site/docs/code/mysql/ |
| Docusaurus site root | /opt/docker-data/apps/docusaurus/site/ |
| Migration knowledge | /opt/docker-data/apps/docusaurus/site/docs/knowledge/docusaurus/11. Migration/ |
| Docker container name | docusaurus |
| App working directory (inside container) | /app |
Docker Commands
# Check container status
sudo docker ps --format '{{.Names}} {{.Status}}' | grep docu
# Run Docusaurus build (verification)
sudo docker exec docusaurus sh -c "cd /app && npx docusaurus build --no-minify 2>&1 | tail -30"
# Restart container after changes
sudo docker restart docusaurus
2. Problem State (Post-Migration)
After the initial migration from Notion, the MySQL documentation Modules 10–18 exhibited two critical issues:
A. Structural Defect (Sidebar)
- Issue: Clicking a parent category (e.g., "10. Constraints & Indexes") expanded the menu but did not show the introduction page.
- Cause: The
_category_.jsonfiles were configured as generic containers ("generated-index") instead of linking to the module'sindex.mdx. - Impact: Poor navigation experience; users couldn't easily access the module overview.
B. Content Quality Defect
- Issue: Lesson files were extremely thin placeholders (~1.5KB / 50–70 lines).
- Format: Repetitive, shallow structure: Introduction → Reference Table → Small Code Snippet → Pitfalls Table → Quick Reference.
- Missing Elements: No conceptual explanations, no step-by-step walkthroughs, no real-world use cases, no exercises, no diagrams.
- Impact: The documentation was reference-only and unsuitable for learning.
C. Modules NOT Affected
- Modules 1–9: Already high quality from earlier, more careful migration (~7–22KB per lesson).
- Module 19 (Backup & Recovery): Already comprehensive (~8KB / ~330 lines per lesson). Used as the quality benchmark.
3. Structural Fix (Sidebar)
We standardized the _category_.json configuration across all modules 07–18 to treat the index.mdx file as the category landing page.
File: docs/code/mysql/<module-folder>/_category_.json
Before (broken):
{
"label": "10. Constraints & Indexes",
"position": 10,
"link": {
"type": "generated-index"
}
}
After (fixed):
{
"label": "10. Constraints & Indexes",
"position": 10,
"link": {
"type": "doc",
"id": "index"
}
}
Modules fixed: 07, 08, 10, 11, 12, 13, 14, 15, 16, 17, 18 (all that had generated-index).
Outcome: Clicking the sidebar item now renders the comprehensive module overview defined in index.mdx.
4. Content Rewrite Strategy
A. Quality Standard ("Module 19 Format")
Every rewritten lesson follows this mandatory structure:
---
title: Lesson Title
description: One-line description for SEO and sidebar hover.
sidebar_position: N
---
:::tip[Learning Focus]
Use this lesson to understand **Topic** — one-sentence goal.
:::
## 1. Concept Overview ← "The Why" - theory, architecture, when to use
## 2. Basic Syntax & Rules ← "The How" - command structure, parameter tables
## 3. Step-by-Step Examples ← 2–4 progressive scenarios (Setup → Execute → Verify)
## 4. Practical Use Cases ← 3–5 real-world business scenarios
## 5. Common Mistakes ← Table: Mistake | What Happens | How to Fix
## 6. Best Practices ← Bulleted list of do's and don'ts
## 7. Hands-On Practice ← 2–3 graded exercises (Easy / Medium / Advanced)
## 8. Connection to Other Concepts ← Table linking to related topics
## 9. Visual Learning Diagram ← Mermaid diagram (flowchart, ER, sequence)
## Quick Reference ← Copy-paste-ready SQL snippets
## What's Next ← Link to next lesson
B. Target Metrics
| Metric | Minimum | Ideal | Maximum |
|---|---|---|---|
| Lines per lesson | 200 | 300–350 | 470 |
| File size (KB) | 6 | 9–11 | 13 |
| Code examples | 3 | 5–8 | 12 |
| Exercises | 2 | 3 | 5 |
| Mermaid diagrams | 1 | 1 | 2 |
C. Frontmatter Convention
Every lesson file uses this exact frontmatter format:
---
title: Human-Readable Lesson Title
description: One sentence describing the lesson for SEO and sidebar tooltips.
sidebar_position: 1 # Sequential within the module (1, 2, 3...)
---
Rules:
- No
idfield — Docusaurus derives it from the filename. - No
sidebar_label— usestitleby default. sidebar_positionstarts at 1 within each module folder.
D. index.mdx Convention
Every module folder contains an index.mdx that serves as the landing page:
---
title: N. Module Title
description: One-line module description.
sidebar_position: 1
---
# N. Module Title
Brief paragraph describing the module scope.
## Lessons
- [Lesson Title](./01-lesson-slug) — short description
- [Lesson Title](./02-lesson-slug) — short description
## Summary Table (optional)
| Concept | Description |
|---|---|
## What's Next
- Continue to [Next Module](../next-module/)
E. Cross-Reference Pattern
Lessons link to each other using relative paths:
<!-- Within same module -->
- [Next Lesson](./02-next-lesson)
<!-- To another module -->
- [Related Topic](../17-user-management-and-security/)
F. Consolidation Rules
When original thin files cover topics that logically belong together, consolidate:
| Module | Original Files (Thin) | New Files (Comprehensive) |
|---|---|---|
| 17. Security | 01-creating-users-and-grants.mdx (54 lines)02-roles-authentication-and-password-policy.mdx (56 lines)03-security-hardening-checklist.mdx (47 lines) | 01-users-roles-and-privileges.mdx (357 lines)02-security-hardening.mdx (378 lines) |
| 18. Performance | 01-explain-and-query-plans.mdx (58 lines)02-index-tuning-and-query-refactoring.mdx (59 lines)03-server-level-optimization.mdx (54 lines) | 01-query-profiling-and-explain.mdx (367 lines)02-server-configuration-tuning.mdx (386 lines) |
After consolidation: Delete old files and update index.mdx to reference new filenames.
5. Complete File Inventory
Before vs After (All Rewritten Files)
| File | Before (lines) | Before (KB) | After (lines) | After (KB) |
|---|---|---|---|---|
| Module 10 | ||||
01-primary-and-foreign-keys.mdx | 65 | 1.9 | 356 | 13.3 |
02-column-and-table-constraints.mdx | 61 | 1.9 | 380 | 12.5 |
03-index-strategy-and-maintenance.mdx | 65 | 1.9 | 384 | 11.4 |
| Module 11 | ||||
01-current-date-and-time-functions.mdx | 55 | 1.5 | 311 | 10.5 |
02-formatting-and-parsing-dates.mdx | 60 | 1.6 | 338 | 10.6 |
03-date-arithmetic-and-difference.mdx | 58 | 1.6 | 333 | 10.3 |
| Module 12 | ||||
01-creating-and-managing-views.mdx | 62 | 1.7 | 347 | 9.9 |
02-updatable-vs-read-only-views.mdx | 53 | 1.5 | 357 | 11.5 |
| Module 13 | ||||
01-stored-procedures-basics.mdx | 73 | 1.9 | 380 | 11.1 |
02-user-defined-functions.mdx | 68 | 1.8 | 339 | 9.6 |
03-control-flow-and-error-handling.mdx | 67 | 1.8 | 467 | 12.6 |
| Module 14 | ||||
01-trigger-fundamentals.mdx | 60 | 1.6 | 362 | 10.4 |
02-audit-and-validation-triggers.mdx | 55 | 1.5 | 438 | 12.5 |
| Module 15 | ||||
01-event-scheduler-basics.mdx | 58 | 1.5 | 366 | 10.3 |
02-recurring-maintenance-events.mdx | 62 | 1.7 | 376 | 11.4 |
| Module 16 | ||||
01-acid-and-transaction-control.mdx | 63 | 1.7 | 374 | 11.1 |
02-isolation-levels-and-locking.mdx | 61 | 1.6 | 348 | 11.2 |
03-deadlocks-and-retry-patterns.mdx | 55 | 1.5 | 363 | 11.4 |
| Module 17 (consolidated 3→2) | ||||
01-users-roles-and-privileges.mdx | — | — | 357 | 10.3 |
02-security-hardening.mdx | — | — | 378 | 10.4 |
| Module 18 (consolidated 3→2) | ||||
01-query-profiling-and-explain.mdx | — | — | 367 | 11.3 |
02-server-configuration-tuning.mdx | — | — | 386 | 10.9 |
Total: 22 final files, ~250 KB of new documentation.
6. MDX Gotchas & Common Build Errors
Future agents must be aware of these Docusaurus MDX issues:
| Issue | Example | Fix |
|---|---|---|
Unescaped < in text | WHERE col > 0 AND col < 100 | Use < → WHERE col > 0 AND col < 100 |
Unescaped < in tables | BETWEEN, >, < | Use < → BETWEEN, >, < |
Unescaped { in text | SET @var = {value} | Wrap in backticks: `{value}` |
| JSX-like expressions | <placeholder> outside code blocks | Wrap in backticks: `<placeholder>` |
| Comments in JSON code blocks | // This is a comment inside JSON | JSON doesn't support comments — remove them or use jsonc language |
| Angle brackets in admonitions | :::tip <Title> | Remove angle brackets from admonition titles |
| HTML tags in Mermaid labels | id[<b>Label</b>] | Use quotes: id["Label"] |
How to Diagnose
# Run build — error output shows exact file, line, and column
sudo docker exec docusaurus sh -c "cd /app && npx docusaurus build --no-minify 2>&1 | tail -30"
The error message includes:
- File path: Which
.mdxfile failed - Line and column: Exact position of the problem character
- Error type: Usually
Unexpected characterwith the offending character
7. Execution Workflow (For Future Agents)
When performing a similar content improvement task:
Step 1: Audit
# Check file sizes to identify thin content
find /opt/docker-data/apps/docusaurus/site/docs/code/mysql/ -name '*.mdx' ! -name 'index.mdx' \
-exec sh -c 'for f; do lines=$(wc -l < "$f"); size=$(stat -c %s "$f"); printf "%-60s %4d lines %6d bytes\n" "$f" "$lines" "$size"; done' _ {} +
Files under 3KB / 100 lines are likely thin placeholders that need rewriting.
Step 2: Identify Quality Benchmark
Find a module in the same project that is already high quality. In this project:
- Module 19 (Backup & Recovery): ~8KB per lesson
- Module 03 (Basic SQL Operations): ~12KB per lesson
Step 3: Rewrite In-Place
- Overwrite each
.mdxfile with comprehensive content. - Follow the standard structure (Section 4A above).
- Preserve the
sidebar_positionvalue.
Step 4: Handle Consolidation
If multiple thin files cover overlapping topics:
- Create new files with better names
- Delete the old files
- Update
index.mdxto reference new filenames
Step 5: Verify
- Check file sizes (all should be >6KB)
- Run Docusaurus build
- Fix any MDX syntax errors
- Confirm sidebar navigation works
8. Folder Structure Reference
docs/code/mysql/
├── _category_.json # Top-level category config
├── index.mdx # MySQL course landing page
├── 01-introduction/ # 2 lessons
├── 02-mysql-data-types/ # 4 lessons
├── 03-basic-sql-operations/ # 9 lessons
├── 04-filtering-and-conditions/ # 6 lessons
├── 05-aggregate-functions/ # 2 lessons
├── 06-joins-and-unions/ # 6 lessons
├── 07-grouping-and-filtering/ # 4 lessons
├── 08-advanced-sql-features/ # 4 lessons
├── 09-database-management/ # 5 lessons
├── 10-constraints-and-indexes/ # 3 lessons ← REWRITTEN
├── 11-date-and-time-functions/ # 3 lessons ← REWRITTEN
├── 12-views/ # 2 lessons ← REWRITTEN
├── 13-stored-procedures-and-functions/ # 3 lessons ← REWRITTEN
├── 14-triggers/ # 2 lessons ← REWRITTEN (was 3)
├── 15-event-scheduler/ # 2 lessons ← REWRITTEN (was 3)
├── 16-transactions-and-concurrency/ # 3 lessons ← REWRITTEN
├── 17-user-management-and-security/ # 2 lessons ← REWRITTEN (was 3)
├── 18-performance-optimization/ # 2 lessons ← REWRITTEN (was 3)
└── 19-backup-and-recovery/ # 4 lessons (untouched — benchmark)
Each module folder contains:
_category_.json— sidebar configurationindex.mdx— module landing/overview page01-lesson-name.mdx,02-lesson-name.mdx, etc. — individual lessons
9. Artifacts
| Artifact | Path |
|---|---|
| Task checklist | /home/rezriz/.gemini/antigravity/brain/d677c38a-4d55-4e16-bb15-99e7d51c345e/task.md |
| Implementation plan | /home/rezriz/.gemini/antigravity/brain/d677c38a-4d55-4e16-bb15-99e7d51c345e/implementation_plan.md |
| Walkthrough | /home/rezriz/.gemini/antigravity/brain/d677c38a-4d55-4e16-bb15-99e7d51c345e/walkthrough.md |
| This migration log | /opt/docker-data/apps/docusaurus/site/docs/knowledge/docusaurus/11. Migration/mysql-migration-and-quality-log.mdx |