sqlew 3.7.3 → 3.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/LICENSE +0 -0
  3. package/README.md +2 -2
  4. package/assets/config.example.toml +0 -0
  5. package/assets/kanban-style.png +0 -0
  6. package/assets/sample-agents/README.md +0 -0
  7. package/assets/sample-agents/sqlew-architect.md +0 -0
  8. package/assets/sample-agents/sqlew-researcher.md +0 -0
  9. package/assets/sample-agents/sqlew-scrum-master.md +0 -0
  10. package/assets/schema.sql +0 -0
  11. package/assets/sqlew-logo.png +0 -0
  12. package/dist/cli/db-export.d.ts +29 -0
  13. package/dist/cli/db-export.d.ts.map +1 -0
  14. package/dist/cli/db-export.js +251 -0
  15. package/dist/cli/db-export.js.map +1 -0
  16. package/dist/cli/db-import.d.ts +31 -0
  17. package/dist/cli/db-import.d.ts.map +1 -0
  18. package/dist/cli/db-import.js +258 -0
  19. package/dist/cli/db-import.js.map +1 -0
  20. package/dist/cli.js +24 -2
  21. package/dist/cli.js.map +1 -1
  22. package/dist/tests/migrations/test-all-versions-real.js +3 -2
  23. package/dist/tests/migrations/test-all-versions-real.js.map +1 -1
  24. package/dist/types.d.ts +121 -0
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/utils/exporter/export.d.ts +100 -0
  27. package/dist/utils/exporter/export.d.ts.map +1 -0
  28. package/dist/utils/exporter/export.js +363 -0
  29. package/dist/utils/exporter/export.js.map +1 -0
  30. package/dist/utils/importer/import.d.ts +29 -0
  31. package/dist/utils/importer/import.d.ts.map +1 -0
  32. package/dist/utils/importer/import.js +514 -0
  33. package/dist/utils/importer/import.js.map +1 -0
  34. package/dist/utils/importer/master-tables.d.ts +18 -0
  35. package/dist/utils/importer/master-tables.d.ts.map +1 -0
  36. package/dist/utils/importer/master-tables.js +255 -0
  37. package/dist/utils/importer/master-tables.js.map +1 -0
  38. package/dist/utils/importer/topological-sort.d.ts +61 -0
  39. package/dist/utils/importer/topological-sort.d.ts.map +1 -0
  40. package/dist/utils/importer/topological-sort.js +143 -0
  41. package/dist/utils/importer/topological-sort.js.map +1 -0
  42. package/docs/ACCEPTANCE_CRITERIA.md +0 -0
  43. package/docs/AI_AGENT_GUIDE.md +0 -0
  44. package/docs/ARCHITECTURE.md +0 -0
  45. package/docs/AUTO_FILE_TRACKING.md +0 -1
  46. package/docs/BEST_PRACTICES.md +0 -0
  47. package/docs/CONFIGURATION.md +0 -0
  48. package/docs/DATABASE_AUTH.md +1 -2
  49. package/docs/DECISION_CONTEXT.md +0 -0
  50. package/docs/DECISION_TO_TASK_MIGRATION_GUIDE.md +0 -0
  51. package/docs/GIT_AWARE_AUTO_COMPLETE.md +0 -0
  52. package/docs/SHARED_CONCEPTS.md +0 -0
  53. package/docs/SPECIALIZED_AGENTS.md +0 -0
  54. package/docs/TASK_ACTIONS.md +0 -0
  55. package/docs/TASK_DEPENDENCIES.md +0 -0
  56. package/docs/TASK_LINKING.md +0 -0
  57. package/docs/TASK_MIGRATION.md +0 -0
  58. package/docs/TASK_OVERVIEW.md +0 -0
  59. package/docs/TASK_PRUNING.md +0 -0
  60. package/docs/TASK_SYSTEM.md +0 -0
  61. package/docs/TOOL_REFERENCE.md +0 -2
  62. package/docs/TOOL_SELECTION.md +0 -0
  63. package/docs/WORKFLOWS.md +0 -0
  64. package/docs/{DATABASE_MIGRATION.md → cli/DATABASE_MIGRATION.md} +71 -32
  65. package/docs/cli/DATA_EXPORT_IMPORT.md +400 -0
  66. package/docs/cli/README.md +227 -0
  67. package/package.json +3 -2
  68. package/docs/BASEADAPTER_IMPLEMENTATION.md +0 -399
  69. package/docs/HELP_PREVIEW_COMPARISON.md +0 -259
  70. package/docs/MIGRATION_CHAIN.md +0 -293
  71. package/docs/MIGRATION_v2.md +0 -538
  72. package/docs/MIGRATION_v3.3.md +0 -602
  73. package/docs/MIGRATION_v3.6.0.md +0 -170
  74. package/docs/MULTI_PROJECT_ARCHITECTURE.md +0 -497
@@ -1,259 +0,0 @@
1
- # Task Tool Help Documentation - Before/After Comparison
2
-
3
- ## Overview
4
- This document shows the changes made to the task tool `help` action to expose the automatic file watching feature to AI agents.
5
-
6
- ---
7
-
8
- ## BEFORE (Original Help Output)
9
-
10
- ### Header Section
11
- ```json
12
- {
13
- "tool": "task",
14
- "description": "Kanban Task Watcher for managing tasks with AI-optimized lifecycle states",
15
- "note": "💡 TIP: Use action: \"example\" to see comprehensive usage scenarios and real-world examples for all task actions."
16
- }
17
- ```
18
-
19
- **Missing:** No mention of automatic file watching feature
20
-
21
- ### Link Action (Original)
22
- ```json
23
- {
24
- "link": {
25
- "description": "Link task to decision/constraint/file",
26
- "required_params": ["task_id", "link_type", "target_id"],
27
- "optional_params": ["link_relation"],
28
- "link_types": ["decision", "constraint", "file"],
29
- "example": {
30
- "action": "link",
31
- "task_id": 5,
32
- "link_type": "decision",
33
- "target_id": "auth_method",
34
- "link_relation": "implements"
35
- }
36
- }
37
- }
38
- ```
39
-
40
- **Missing:** No indication that file linking activates watcher
41
-
42
- ### Documentation Section (Original)
43
- ```json
44
- {
45
- "priority_levels": {
46
- "1": "low",
47
- "2": "medium (default)",
48
- "3": "high",
49
- "4": "critical"
50
- },
51
- "documentation": {
52
- "task_overview": "docs/TASK_OVERVIEW.md - Lifecycle, status transitions, auto-stale detection (363 lines, ~10k tokens)",
53
- "task_actions": "docs/TASK_ACTIONS.md - All action references with examples (854 lines, ~21k tokens)",
54
- ...
55
- }
56
- }
57
- ```
58
-
59
- **Missing:** No auto_file_tracking section explaining the feature
60
-
61
- ---
62
-
63
- ## AFTER (Updated Help Output)
64
-
65
- ### Header Section ✅ ENHANCED
66
- ```json
67
- {
68
- "tool": "task",
69
- "description": "Kanban Task Watcher for managing tasks with AI-optimized lifecycle states",
70
- "note": "💡 TIP: Use action: \"example\" to see comprehensive usage scenarios and real-world examples for all task actions.",
71
- "important": "🚨 AUTOMATIC FILE WATCHING: Linking files to tasks activates automatic file change monitoring and acceptance criteria validation. This provides 97% token reduction vs manual tracking. See auto_file_tracking section below."
72
- }
73
- ```
74
-
75
- **✨ NEW:** Prominent warning about automatic file watching feature
76
- **🎯 Impact:** AI agents immediately see this critical feature exists
77
-
78
- ### Link Action ✅ ENHANCED
79
- ```json
80
- {
81
- "link": {
82
- "description": "Link task to decision/constraint/file",
83
- "required_params": ["task_id", "link_type", "target_id"],
84
- "optional_params": ["link_relation"],
85
- "link_types": ["decision", "constraint", "file"],
86
- "file_linking_behavior": "⚠️ IMPORTANT: When link_type=\"file\", this action ACTIVATES AUTOMATIC FILE WATCHING. The file watcher monitors linked files for changes and validates acceptance criteria when files are saved. This provides 97% token reduction compared to manual file change tracking.",
87
- "example": {
88
- "action": "link",
89
- "task_id": 5,
90
- "link_type": "decision",
91
- "target_id": "auth_method",
92
- "link_relation": "implements"
93
- }
94
- }
95
- }
96
- ```
97
-
98
- **✨ NEW:** `file_linking_behavior` field with prominent warning
99
- **🎯 Impact:** AI agents understand that file linking is not passive documentation
100
-
101
- ### Documentation Section ✅ ENHANCED
102
- ```json
103
- {
104
- "priority_levels": {
105
- "1": "low",
106
- "2": "medium (default)",
107
- "3": "high",
108
- "4": "critical"
109
- },
110
- "auto_file_tracking": {
111
- "description": "Automatic file watching and acceptance criteria validation (97% token reduction)",
112
- "how_it_works": [
113
- "1. Link files to tasks using the link action with link_type=\"file\"",
114
- "2. File watcher automatically activates and monitors linked files",
115
- "3. When files are saved, watcher detects changes",
116
- "4. If task has acceptance_criteria, watcher validates criteria against changes",
117
- "5. Results appear in terminal output with pass/fail status"
118
- ],
119
- "requirements": [
120
- "Task must have files linked via link action",
121
- "File paths must be relative to project root (e.g., \"src/api/auth.ts\")",
122
- "Watcher only monitors files explicitly linked to tasks"
123
- ],
124
- "token_efficiency": "File watching happens in background. No MCP tokens consumed until you query status. Manual file tracking would cost ~500-1000 tokens per file check.",
125
- "documentation_reference": "docs/AUTO_FILE_TRACKING.md - Complete guide with examples"
126
- },
127
- "documentation": {
128
- "task_overview": "docs/TASK_OVERVIEW.md - Lifecycle, status transitions, auto-stale detection (363 lines, ~10k tokens)",
129
- "task_actions": "docs/TASK_ACTIONS.md - All action references with examples (854 lines, ~21k tokens)",
130
- ...
131
- }
132
- }
133
- ```
134
-
135
- **✨ NEW:** Complete `auto_file_tracking` section with:
136
- - Clear description of the feature and token benefits
137
- - 5-step workflow explaining how it works
138
- - Requirements for activation
139
- - Token efficiency explanation
140
- - Reference to detailed documentation
141
-
142
- **🎯 Impact:** AI agents have complete understanding without reading external docs
143
-
144
- ---
145
-
146
- ## Example Action Changes
147
-
148
- ### BEFORE (Original Example)
149
- ```json
150
- {
151
- "scenario": "Link task to file",
152
- "request": "{ action: \"link\", task_id: 5, link_type: \"file\", target_id: \"src/api/auth.ts\", link_relation: \"modifies\" }",
153
- "explanation": "Indicate which files the task will modify"
154
- }
155
- ```
156
-
157
- **❌ Problem:** Sounds passive - "Indicate" suggests documentation only
158
-
159
- ### AFTER (Updated Example) ✅
160
- ```json
161
- {
162
- "scenario": "Link task to file",
163
- "request": "{ action: \"link\", task_id: 5, link_type: \"file\", target_id: \"src/api/auth.ts\", link_relation: \"modifies\" }",
164
- "explanation": "Activates automatic file watching for the task (97% token reduction vs manual tracking)",
165
- "behavior": "File watcher monitors linked files and validates acceptance criteria when files change"
166
- }
167
- ```
168
-
169
- **✨ NEW:**
170
- - Active voice: "Activates" (not "Indicate")
171
- - Token reduction benefit highlighted
172
- - Explicit behavior description
173
-
174
- **🎯 Impact:** AI agents understand this is an active feature, not passive documentation
175
-
176
- ---
177
-
178
- ## Key Improvements Summary
179
-
180
- ### 1. Discoverability ✅
181
- - **Before:** Feature completely hidden from MCP tool interface
182
- - **After:** Prominently displayed in 3 locations (header, link action, dedicated section)
183
-
184
- ### 2. Understanding ✅
185
- - **Before:** No explanation of how/why to use file linking
186
- - **After:** 5-step workflow, requirements, and token efficiency clearly documented
187
-
188
- ### 3. Motivation ✅
189
- - **Before:** No indication of benefits
190
- - **After:** "97% token reduction" mentioned 3 times to motivate usage
191
-
192
- ### 4. Behavior Clarity ✅
193
- - **Before:** File linking sounded like passive documentation
194
- - **After:** Clearly stated as active feature that "activates" watching
195
-
196
- ---
197
-
198
- ## Token Impact Analysis
199
-
200
- ### Help Documentation Size
201
- - **Before:** ~1,200 tokens
202
- - **After:** ~1,400 tokens (+200 tokens)
203
- - **Increase:** 16.7%
204
-
205
- ### Value Gained
206
- - **Feature discoverability:** Infinite value (feature was invisible before)
207
- - **Token savings per usage:** 500-1,000 tokens per file check avoided
208
- - **ROI:** First use of file watcher saves 3-5x the documentation cost
209
-
210
- ### Net Token Efficiency
211
- If AI agents use file watching just **once**, they save more tokens than the documentation costs. The 200-token investment pays for itself immediately.
212
-
213
- ---
214
-
215
- ## Files Modified
216
-
217
- 1. **src/tools/tasks.ts** (lines 1184-1371)
218
- - Added `important` field to header (line 1189)
219
- - Added `file_linking_behavior` to link action (line 1258)
220
- - Added `auto_file_tracking` section (lines 1355-1371)
221
-
222
- 2. **src/index.ts** (lines 1370-1375)
223
- - Updated file linking example explanation
224
- - Added behavior description
225
-
226
- ---
227
-
228
- ## Verification Checklist
229
-
230
- - [x] Header prominently mentions automatic file watching
231
- - [x] Link action clearly states watcher activation
232
- - [x] Complete auto_file_tracking section with workflow
233
- - [x] Example action uses active voice ("Activates")
234
- - [x] Token reduction benefit (97%) mentioned multiple times
235
- - [x] Documentation reference provided for deep dive
236
- - [x] All changes maintain existing help structure
237
- - [x] TypeScript compiles successfully (to be verified)
238
-
239
- ---
240
-
241
- ## Expected AI Agent Behavior Change
242
-
243
- ### Before These Changes
244
- ```
245
- AI Agent: "I'll link the files to document which files this task affects"
246
- Result: Feature activation happens, but agent doesn't realize it or leverage it
247
- ```
248
-
249
- ### After These Changes
250
- ```
251
- AI Agent: "I'll link these files to activate automatic file watching (97% token reduction).
252
- The watcher will monitor changes and validate acceptance criteria automatically."
253
- Result: Feature activation is intentional and understood, agent can explain benefits to user
254
- ```
255
-
256
- ---
257
-
258
- **Status:** Documentation updates complete ✅
259
- **Next Step:** Implement watcher status query action (task #93-95)
@@ -1,293 +0,0 @@
1
- # Migration Chain Documentation
2
-
3
- > **⚠️ HISTORICAL DOCUMENT (v1.0.0 - v2.1.0)**
4
- >
5
- > This document describes the **old custom migration system** used before v3.6.2.
6
- >
7
- > **As of v3.6.2**, sqlew uses **Knex.js migrations only**. See the migration files in:
8
- > - `src/migrations/knex/upgrades/` - Version upgrade paths
9
- > - `src/migrations/knex/bootstrap/` - Fresh install schema
10
- > - `src/migrations/knex/enhancements/` - Feature additions
11
- >
12
- > This document is kept for historical reference only.
13
-
14
- ---
15
-
16
- This document describes the complete migration path from v1.0.0 to v2.1.0 for mcp-sqlew databases.
17
-
18
- ## Schema Version History
19
-
20
- ### v1.0.0 (Initial Release)
21
- - **Table Names:** No prefixes
22
- - Master: `agents`, `files`, `context_keys`, `constraint_categories`, `layers`, `tags`, `scopes`
23
- - Transaction: `decisions`, `decisions_numeric`, `decision_history`, `decision_tags`, `decision_scopes`, `agent_messages`, `file_changes`, `constraints`, `constraint_tags`
24
- - Views: `tagged_decisions`, `active_context`, `layer_summary`, `unread_messages_by_priority`, `recent_file_changes`, `tagged_constraints`
25
- - Triggers: `auto_delete_old_messages`, `auto_delete_old_file_changes`, `record_decision_history`
26
- - **Configuration:** No `config` table (hardcoded settings)
27
- - **Comments:** Japanese
28
-
29
- ### v1.1.0 - v1.1.2 & v2.0.0 (Table Prefixes)
30
- - **Table Names:** WITH prefixes
31
- - Master: `m_agents`, `m_files`, `m_context_keys`, `m_constraint_categories`, `m_layers`, `m_tags`, `m_scopes`, **`m_config` (NEW)**
32
- - Transaction: `t_decisions`, `t_decisions_numeric`, `t_decision_history`, `t_decision_tags`, `t_decision_scopes`, `t_agent_messages`, `t_file_changes`, `t_constraints`, `t_constraint_tags`
33
- - Views: `v_tagged_decisions`, `v_active_context`, `v_layer_summary`, `v_unread_messages_by_priority`, `v_recent_file_changes`, `v_tagged_constraints`
34
- - Triggers: `trg_record_decision_history` (auto-delete triggers removed)
35
- - **Configuration:** `m_config` table added with weekend-aware auto-deletion settings
36
- - **Comments:** Japanese
37
- - **Notes:**
38
- - v1.1.1: Hotfix for migration failure (creates m_config if missing)
39
- - v1.1.2: Hotfix for schema validation (checks for prefixed names)
40
- - v2.0.0: API changes only (20 tools → 6 action-based tools), **no schema changes**
41
-
42
- ### v2.1.0 (Feature Release - Current)
43
- - **New Tables:**
44
- - `t_activity_log` - Automatic activity logging (agent_id, action_type, target, layer_id, details, ts)
45
- - `t_decision_templates` - Decision templates (name, defaults, required_fields, created_by, ts)
46
- - **New Triggers:**
47
- - `trg_log_decision_set` - Auto-log decision creation
48
- - `trg_log_decision_update` - Auto-log decision updates
49
- - `trg_log_message_send` - Auto-log message sending
50
- - `trg_log_file_record` - Auto-log file changes
51
- - **New Indexes:**
52
- - `idx_activity_log_ts` - Time-based activity queries
53
- - `idx_activity_log_agent` - Agent-based activity queries
54
- - `idx_activity_log_action` - Action type filtering
55
- - **Comments:** English (translated from Japanese)
56
- - **Built-in Data:** 5 decision templates seeded
57
-
58
- ## Migration Scripts
59
-
60
- ### 1. v1.0.0 → v1.1.x: add-table-prefixes.ts
61
- **Purpose:** Rename all tables to add category-based prefixes and create m_config table
62
-
63
- **Actions:**
64
- 1. Drop old views (they reference old table names)
65
- 2. Drop old triggers
66
- 3. Rename master tables (agents → m_agents, etc.)
67
- 4. Rename transaction tables (decisions → t_decisions, etc.)
68
- 5. Create m_config table if missing
69
- 6. Insert default config values
70
- 7. Schema initialization creates new views/triggers
71
-
72
- **Transaction:** Yes (rollback on failure)
73
- **Auto-detect:** Checks for existence of `agents` (old) and absence of `m_agents` (new)
74
-
75
- ### 2. v1.1.x / v2.0.0 → v2.1.0: add-v2.1.0-features.ts
76
- **Purpose:** Add activity logging and template system
77
-
78
- **Actions:**
79
- 1. Create `t_activity_log` table with 3 indexes
80
- 2. Create `t_decision_templates` table
81
- 3. Create 4 activity logging triggers
82
- 4. Seed 5 built-in templates
83
-
84
- **Transaction:** Yes (rollback on failure)
85
- **Auto-detect:** Checks for absence of `t_activity_log` OR `t_decision_templates`
86
-
87
- ## Migration Execution Order
88
-
89
- The migrations run automatically on server startup in this order:
90
-
91
- ```
92
- 1. Check v1.0.0 → v1.1.x migration (add-table-prefixes.ts)
93
- ├─ If needed: Run migration
94
- ├─ Run schema initialization (creates views/triggers)
95
- └─ Continue to next check
96
-
97
- 2. Check v1.1.x/v2.0.0 → v2.1.0 migration (add-v2.1.0-features.ts)
98
- ├─ If needed: Run migration
99
- └─ Continue
100
-
101
- 3. Validate schema integrity
102
- ├─ Check all required tables exist
103
- ├─ Check all required views exist
104
- ├─ Check all required triggers exist
105
- ├─ Verify standard data (5 layers, 3 categories, 10+ tags)
106
- └─ Exit with error if validation fails
107
-
108
- 4. Start MCP server
109
- ```
110
-
111
- ## Complete Migration Paths
112
-
113
- ### Path 1: v1.0.0 → v2.1.0 (Full Chain)
114
- ```
115
- v1.0.0 (no prefixes, no config)
116
- ↓ add-table-prefixes.ts
117
- v1.1.0 (prefixes, m_config added)
118
- ↓ add-v2.1.0-features.ts
119
- v2.1.0 (activity_log, templates added)
120
- ```
121
-
122
- **Steps:**
123
- 1. Start server with v1.0.0 database
124
- 2. Detects unprefixed tables → runs add-table-prefixes.ts
125
- 3. Migration adds prefixes and m_config table
126
- 4. Schema initialization creates new views/triggers
127
- 5. Detects missing v2.1.0 tables → runs add-v2.1.0-features.ts
128
- 6. Migration adds t_activity_log, t_decision_templates, 4 triggers
129
- 7. Schema validation passes
130
- 8. Server starts with v2.1.0 schema
131
-
132
- ### Path 2: v1.1.x / v2.0.0 → v2.1.0 (Single Migration)
133
- ```
134
- v1.1.0-v1.1.2 or v2.0.0 (prefixes, m_config present)
135
- ↓ add-v2.1.0-features.ts
136
- v2.1.0 (activity_log, templates added)
137
- ```
138
-
139
- **Steps:**
140
- 1. Start server with v1.1.x or v2.0.0 database
141
- 2. Detects prefixed tables exist → skips add-table-prefixes.ts
142
- 3. Detects missing v2.1.0 tables → runs add-v2.1.0-features.ts
143
- 4. Migration adds t_activity_log, t_decision_templates, 4 triggers
144
- 5. Schema validation passes
145
- 6. Server starts with v2.1.0 schema
146
-
147
- ### Path 3: Fresh Install → v2.1.0 (No Migration)
148
- ```
149
- Empty database
150
- ↓ schema initialization
151
- v2.1.0 (full schema created)
152
- ```
153
-
154
- **Steps:**
155
- 1. Start server with empty/new database path
156
- 2. No existing schema detected
157
- 3. Schema initialization runs (executes assets/schema.sql)
158
- 4. All tables, views, triggers created directly from v2.1.0 schema
159
- 5. Schema validation passes
160
- 6. Server starts with v2.1.0 schema
161
-
162
- ## Schema Validation (v2.1.0 Requirements)
163
-
164
- The schema validator (`src/schema.ts`) checks for:
165
-
166
- **Tables (19 total):**
167
- - Master (8): m_agents, m_files, m_context_keys, m_constraint_categories, m_layers, m_tags, m_scopes, m_config
168
- - Transaction (11): t_decisions, t_decisions_numeric, t_decision_history, t_decision_tags, t_decision_scopes, t_agent_messages, t_file_changes, t_constraints, t_constraint_tags, **t_activity_log**, **t_decision_templates**
169
-
170
- **Views (6 total):**
171
- - v_tagged_decisions, v_active_context, v_layer_summary, v_unread_messages_by_priority, v_recent_file_changes, v_tagged_constraints
172
-
173
- **Triggers (5 total):**
174
- - trg_record_decision_history
175
- - **trg_log_decision_set** (NEW in v2.1.0)
176
- - **trg_log_decision_update** (NEW in v2.1.0)
177
- - **trg_log_message_send** (NEW in v2.1.0)
178
- - **trg_log_file_record** (NEW in v2.1.0)
179
-
180
- **Standard Data:**
181
- - 5 layers (presentation, business, data, infrastructure, cross-cutting)
182
- - 3 constraint categories (performance, architecture, security)
183
- - 10+ tags (authentication, authorization, performance, security, api, database, caching, testing, validation, error-handling)
184
- - 3+ config entries (autodelete_ignore_weekend, autodelete_message_hours, autodelete_file_history_days)
185
-
186
- ## Testing Migration Chain
187
-
188
- ### Test 1: v1.0.0 → v2.1.0
189
- ```bash
190
- # Create v1.0.0 database (use git checkout)
191
- git checkout v1.0.0
192
- node dist/index.js --db-path=.test/v1.0.0.db
193
- # Let it initialize with v1.0.0 schema
194
- # Stop server (Ctrl+C)
195
-
196
- # Upgrade to v2.1.0
197
- git checkout main
198
- npm run build
199
- node dist/index.js --db-path=.test/v1.0.0.db
200
- # Should run BOTH migrations automatically
201
- # Check logs for:
202
- # "Migration required: Adding table prefixes (v1.2.0 -> v1.3.0)"
203
- # "Migration required: Adding v2.1.0 features (v2.0.0 -> v2.1.0)"
204
- ```
205
-
206
- ### Test 2: v2.0.0 → v2.1.0
207
- ```bash
208
- # Create v2.0.0 database
209
- git checkout v2.0.0
210
- npm run build
211
- node dist/index.js --db-path=.test/v2.0.0.db
212
- # Stop server
213
-
214
- # Upgrade to v2.1.0
215
- git checkout main
216
- npm run build
217
- node dist/index.js --db-path=.test/v2.0.0.db
218
- # Should run ONLY v2.1.0 migration
219
- # Check logs for:
220
- # "Migration required: Adding v2.1.0 features (v2.0.0 -> v2.1.0)"
221
- ```
222
-
223
- ### Test 3: Fresh v2.1.0
224
- ```bash
225
- # Fresh install
226
- node dist/index.js --db-path=.test/fresh-v2.1.0.db
227
- # Should initialize directly to v2.1.0
228
- # No migration messages
229
- ```
230
-
231
- ## Rollback Strategy
232
-
233
- If a migration fails:
234
- 1. **Transaction rollback** - All changes reverted automatically
235
- 2. **Database unchanged** - Original schema preserved
236
- 3. **Server exits** - Prevents running with corrupted schema
237
- 4. **Error message displayed** - Clear indication of failure
238
-
239
- To manually rollback:
240
- ```bash
241
- # Restore from backup (recommended)
242
- cp backup.db current.db
243
-
244
- # Or delete and reinitialize
245
- rm .sqlew/sqlew.db
246
- node dist/index.js # Creates fresh v2.1.0 database
247
- ```
248
-
249
- ## Troubleshooting
250
-
251
- ### Migration Doesn't Run
252
- - Check that database file exists and is accessible
253
- - Verify SQLite version supports required features
254
- - Check file permissions
255
-
256
- ### Migration Fails Midway
257
- - Check error message in console
258
- - Database is automatically rolled back
259
- - No partial state - safe to retry
260
-
261
- ### Schema Validation Fails After Migration
262
- - Report as bug (migration should guarantee valid schema)
263
- - Check logs for missing components
264
- - May need to restore from backup or delete database
265
-
266
- ## Future Migrations
267
-
268
- When adding new features in future versions:
269
-
270
- 1. Create new migration script: `src/migrations/add-vX.Y.Z-features.ts`
271
- 2. Implement `needsMigration()`, `runMigration()`, `getMigrationInfo()`
272
- 3. Import in `src/database.ts`
273
- 4. Add check AFTER previous migrations, BEFORE schema validation
274
- 5. Update `src/schema.ts` validation requirements
275
- 6. Update `assets/schema.sql` with new schema
276
- 7. Document in CHANGELOG.md and this file
277
- 8. Test complete migration chain from oldest supported version
278
-
279
- ## Backward Compatibility
280
-
281
- **Database:** v2.1.0 can read and migrate v1.0.0, v1.1.x, and v2.0.0 databases
282
- **API:** v2.0.0 tool calls work unchanged in v2.1.0 (backward compatible)
283
- **Forward Compatibility:** Older versions CANNOT read v2.1.0 databases (missing tables/triggers)
284
-
285
- ## Summary
286
-
287
- - ✅ v1.0.0 → v2.1.0: Full migration chain supported
288
- - ✅ v1.1.x → v2.1.0: Single migration
289
- - ✅ v2.0.0 → v2.1.0: Single migration
290
- - ✅ Fresh install: Direct v2.1.0 schema
291
- - ✅ Transaction-based: Safe rollback on failure
292
- - ✅ Auto-detect: Runs only needed migrations
293
- - ✅ Schema validation: Ensures integrity