sqlew 4.0.0 → 4.0.2
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.
- package/CHANGELOG.md +126 -0
- package/README.md +12 -8
- package/dist/cli/db-dump.d.ts +4 -0
- package/dist/cli/db-dump.d.ts.map +1 -1
- package/dist/cli/db-dump.js +89 -114
- package/dist/cli/db-dump.js.map +1 -1
- package/dist/cli/db-export.d.ts +1 -0
- package/dist/cli/db-export.d.ts.map +1 -1
- package/dist/cli/db-export.js +46 -80
- package/dist/cli/db-export.js.map +1 -1
- package/dist/cli/db-import.d.ts +1 -0
- package/dist/cli/db-import.d.ts.map +1 -1
- package/dist/cli/db-import.js +52 -90
- package/dist/cli/db-import.js.map +1 -1
- package/dist/cli.d.ts +10 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +57 -59
- package/dist/cli.js.map +1 -1
- package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.d.ts.map +1 -1
- package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.js +7 -4
- package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.js.map +1 -1
- package/dist/database/migrations/v4/20251128000000_drop_all_views.d.ts +24 -0
- package/dist/database/migrations/v4/20251128000000_drop_all_views.d.ts.map +1 -0
- package/dist/database/migrations/v4/20251128000000_drop_all_views.js +67 -0
- package/dist/database/migrations/v4/20251128000000_drop_all_views.js.map +1 -0
- package/dist/database/operations/inserts.d.ts.map +1 -1
- package/dist/database/operations/inserts.js +7 -0
- package/dist/database/operations/inserts.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -48
- package/dist/index.js.map +1 -1
- package/dist/tests/database/testing-config.d.ts +4 -0
- package/dist/tests/database/testing-config.d.ts.map +1 -1
- package/dist/tests/database/testing-config.js +1 -1
- package/dist/tests/database/testing-config.js.map +1 -1
- package/dist/tests/docker/native/test-harness.d.ts +56 -1
- package/dist/tests/docker/native/test-harness.d.ts.map +1 -1
- package/dist/tests/docker/native/test-harness.js +221 -5
- package/dist/tests/docker/native/test-harness.js.map +1 -1
- package/dist/tests/feature/vcs/git-aware-completion.test.js +33 -0
- package/dist/tests/feature/vcs/git-aware-completion.test.js.map +1 -1
- package/dist/tests/unit/utils/case-insensitive-validator.test.d.ts +2 -0
- package/dist/tests/unit/utils/case-insensitive-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/case-insensitive-validator.test.js +97 -0
- package/dist/tests/unit/utils/case-insensitive-validator.test.js.map +1 -0
- package/dist/tools/constraints/actions/get.d.ts +2 -2
- package/dist/tools/constraints/actions/get.d.ts.map +1 -1
- package/dist/tools/constraints/actions/get.js +56 -19
- package/dist/tools/constraints/actions/get.js.map +1 -1
- package/dist/tools/context/actions/create-policy.d.ts.map +1 -1
- package/dist/tools/context/actions/create-policy.js +5 -1
- package/dist/tools/context/actions/create-policy.js.map +1 -1
- package/dist/tools/files/actions/get.d.ts +2 -2
- package/dist/tools/files/actions/get.d.ts.map +1 -1
- package/dist/tools/files/actions/get.js +22 -51
- package/dist/tools/files/actions/get.js.map +1 -1
- package/dist/types.d.ts +10 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/case-insensitive-validator.d.ts +102 -0
- package/dist/utils/case-insensitive-validator.d.ts.map +1 -0
- package/dist/utils/case-insensitive-validator.js +144 -0
- package/dist/utils/case-insensitive-validator.js.map +1 -0
- package/dist/utils/exporter/export.d.ts +22 -7
- package/dist/utils/exporter/export.d.ts.map +1 -1
- package/dist/utils/exporter/export.js +33 -49
- package/dist/utils/exporter/export.js.map +1 -1
- package/dist/utils/importer/import.js +64 -27
- package/dist/utils/importer/import.js.map +1 -1
- package/dist/utils/importer/master-tables.d.ts +3 -1
- package/dist/utils/importer/master-tables.d.ts.map +1 -1
- package/dist/utils/importer/master-tables.js +7 -29
- package/dist/utils/importer/master-tables.js.map +1 -1
- package/dist/utils/sql-dump/core/generate-dump.d.ts.map +1 -1
- package/dist/utils/sql-dump/core/generate-dump.js +25 -5
- package/dist/utils/sql-dump/core/generate-dump.js.map +1 -1
- package/dist/utils/sql-dump/core/index-export.d.ts +3 -2
- package/dist/utils/sql-dump/core/index-export.d.ts.map +1 -1
- package/dist/utils/sql-dump/core/index-export.js +9 -9
- package/dist/utils/sql-dump/core/index-export.js.map +1 -1
- package/dist/utils/sql-dump/schema/indexes.d.ts +14 -0
- package/dist/utils/sql-dump/schema/indexes.d.ts.map +1 -1
- package/dist/utils/sql-dump/schema/indexes.js +81 -15
- package/dist/utils/sql-dump/schema/indexes.js.map +1 -1
- package/dist/utils/sql-dump/schema/tables.d.ts +4 -1
- package/dist/utils/sql-dump/schema/tables.d.ts.map +1 -1
- package/dist/utils/sql-dump/schema/tables.js +81 -51
- package/dist/utils/sql-dump/schema/tables.js.map +1 -1
- package/docs/cli/DATABASE_MIGRATION.md +62 -58
- package/docs/cli/DATA_EXPORT_IMPORT.md +403 -103
- package/docs/cli/README.md +95 -45
- package/package.json +4 -6
|
@@ -1,99 +1,101 @@
|
|
|
1
1
|
# Database Migration Guide
|
|
2
2
|
|
|
3
|
-
This guide explains how to generate complete SQL dumps from your mcp-sqlew database for
|
|
4
|
-
or PostgreSQL.
|
|
3
|
+
This guide explains how to generate complete SQL dumps from your mcp-sqlew database for backup and restore operations.
|
|
5
4
|
|
|
6
|
-
##
|
|
7
|
-
|
|
8
|
-
The `db:dump` CLI tool generates complete SQL dumps (CREATE TABLE + INSERT statements) compatible with SQLite,
|
|
9
|
-
MySQL/MariaDB, and PostgreSQL formats. The generated SQL can be imported directly into an empty database without
|
|
10
|
-
additional setup.
|
|
5
|
+
## ⚠️ BREAKING CHANGE (v4.0.2)
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
**SQL dump no longer supports cross-database format conversion.**
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
Starting from v4.0.2, `db:dump` generates SQL for the **same database type only**:
|
|
10
|
+
- SQLite → SQLite ✅
|
|
11
|
+
- MySQL → MySQL ✅
|
|
12
|
+
- PostgreSQL → PostgreSQL ✅
|
|
13
|
+
- SQLite → MySQL ❌ (use JSON instead)
|
|
14
|
+
- SQLite → PostgreSQL ❌ (use JSON instead)
|
|
15
15
|
|
|
16
|
+
**For cross-database migrations**, use JSON export/import:
|
|
16
17
|
```bash
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
npx sqlew db:export backup.json # Export to JSON
|
|
19
|
+
npx sqlew db:import backup.json # Import to target database
|
|
19
20
|
```
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
See [DATA_EXPORT_IMPORT.md](DATA_EXPORT_IMPORT.md) for complete cross-database migration guide.
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
"scripts": {
|
|
26
|
-
"sqlew": "node node_modules/sqlew/dist/cli.js"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
24
|
+
---
|
|
30
25
|
|
|
31
|
-
|
|
26
|
+
## Overview
|
|
27
|
+
|
|
28
|
+
The `db:dump` CLI tool generates complete SQL dumps (CREATE TABLE + INSERT statements) for **same-database-type backup and restore operations**. The generated SQL can be imported directly into an empty database of the same type.
|
|
32
29
|
|
|
33
30
|
## Usage
|
|
34
31
|
|
|
35
|
-
|
|
32
|
+
**No installation required!** Use directly via npx:
|
|
36
33
|
|
|
37
34
|
```bash
|
|
38
|
-
|
|
35
|
+
npx sqlew db:dump <format> [output-file] [key=value ...]
|
|
39
36
|
```
|
|
40
37
|
|
|
41
38
|
**Parameters:**
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
| Parameter | Description | Default |
|
|
41
|
+
|-----------|-------------|---------|
|
|
42
|
+
| `<format>` | Target SQL format: sqlite, mysql, postgresql | **Required** |
|
|
43
|
+
| `[output-file]` | Output file path | stdout |
|
|
44
|
+
| `from=<source>` | Source database type | sqlite |
|
|
45
|
+
| `tables=<list>` | Comma-separated table names | all tables |
|
|
46
|
+
| `chunk-size=<n>` | Rows per INSERT statement | 100 |
|
|
47
|
+
| `on-conflict=<mode>` | error, ignore, replace | error |
|
|
48
|
+
| `exclude-schema=true` | Data-only dump (no CREATE TABLE) | false |
|
|
49
|
+
| `db-path=<path>` | SQLite database path | .sqlew/sqlew.db |
|
|
51
50
|
|
|
52
51
|
**Note:** By default, the dump includes both schema (CREATE TABLE) and data (INSERT) for complete migration.
|
|
53
52
|
|
|
54
|
-
### Generate SQL Dumps
|
|
53
|
+
### Generate SQL Dumps (Same-Database Backup)
|
|
55
54
|
|
|
56
|
-
**
|
|
55
|
+
**SQLite Backup:**
|
|
57
56
|
|
|
58
57
|
```bash
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
# Backup SQLite database (default)
|
|
59
|
+
npx sqlew db:dump sqlite backup-sqlite.sql
|
|
61
60
|
```
|
|
62
61
|
|
|
63
|
-
**
|
|
62
|
+
**MySQL Backup:**
|
|
64
63
|
|
|
65
64
|
```bash
|
|
66
|
-
# Configure connection via environment variables
|
|
65
|
+
# Configure connection via .sqlew/config.toml or environment variables
|
|
67
66
|
export MYSQL_HOST=127.0.0.1
|
|
68
67
|
export MYSQL_PORT=3306
|
|
69
68
|
export MYSQL_USER=youruser
|
|
70
69
|
export MYSQL_PASSWORD=yourpass
|
|
71
70
|
export MYSQL_DATABASE=mcp_context
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
# Backup MySQL database
|
|
73
|
+
npx sqlew db:dump mysql backup-mysql.sql from=mysql
|
|
75
74
|
```
|
|
76
75
|
|
|
77
|
-
**
|
|
76
|
+
**PostgreSQL Backup:**
|
|
78
77
|
|
|
79
78
|
```bash
|
|
80
|
-
# Configure connection via environment variables
|
|
79
|
+
# Configure connection via .sqlew/config.toml or environment variables
|
|
81
80
|
export PG_HOST=localhost
|
|
82
81
|
export PG_PORT=5432
|
|
83
82
|
export PG_USER=postgres
|
|
84
83
|
export PG_PASSWORD=yourpass
|
|
85
84
|
export PG_DATABASE=mcp_context
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
# Backup PostgreSQL database
|
|
87
|
+
npx sqlew db:dump postgresql backup-pg.sql from=postgresql
|
|
89
88
|
```
|
|
90
89
|
|
|
90
|
+
> **Note**: For cross-database migrations (e.g., SQLite → MySQL), use JSON export/import instead.
|
|
91
|
+
> See [DATA_EXPORT_IMPORT.md](DATA_EXPORT_IMPORT.md) for the complete guide.
|
|
92
|
+
|
|
91
93
|
### Selective Table Export
|
|
92
94
|
|
|
93
95
|
Export only specific tables:
|
|
94
96
|
|
|
95
97
|
```bash
|
|
96
|
-
|
|
98
|
+
npx sqlew db:dump mysql partial.sql tables=v4_decisions,v4_tasks,v4_files
|
|
97
99
|
```
|
|
98
100
|
|
|
99
101
|
### Custom Chunk Size
|
|
@@ -101,7 +103,7 @@ node node_modules/sqlew/dist/cli.js db:dump --format mysql --tables t_decisions,
|
|
|
101
103
|
For large tables, adjust INSERT batch size:
|
|
102
104
|
|
|
103
105
|
```bash
|
|
104
|
-
|
|
106
|
+
npx sqlew db:dump mysql dump.sql chunk-size=500
|
|
105
107
|
```
|
|
106
108
|
|
|
107
109
|
### Data-Only Dumps
|
|
@@ -109,7 +111,7 @@ node node_modules/sqlew/dist/cli.js db:dump --format mysql --chunk-size 500 --ou
|
|
|
109
111
|
For advanced use cases where you manage schema separately:
|
|
110
112
|
|
|
111
113
|
```bash
|
|
112
|
-
|
|
114
|
+
npx sqlew db:dump mysql data-only.sql exclude-schema=true
|
|
113
115
|
```
|
|
114
116
|
|
|
115
117
|
This generates INSERT statements without CREATE TABLE, useful for:
|
|
@@ -124,13 +126,13 @@ Handle duplicate keys when importing into existing databases:
|
|
|
124
126
|
|
|
125
127
|
```bash
|
|
126
128
|
# Ignore duplicates (safe for adding new data)
|
|
127
|
-
|
|
129
|
+
npx sqlew db:dump mysql dump.sql on-conflict=ignore
|
|
128
130
|
|
|
129
131
|
# Update existing rows (sync/overwrite mode)
|
|
130
|
-
|
|
132
|
+
npx sqlew db:dump mysql dump.sql on-conflict=replace
|
|
131
133
|
|
|
132
134
|
# Fail on duplicates (default, strict mode)
|
|
133
|
-
|
|
135
|
+
npx sqlew db:dump mysql dump.sql on-conflict=error
|
|
134
136
|
```
|
|
135
137
|
|
|
136
138
|
**Modes:**
|
|
@@ -147,18 +149,20 @@ node node_modules/sqlew/dist/cli.js db:dump --format mysql --on-conflict error -
|
|
|
147
149
|
|
|
148
150
|
---
|
|
149
151
|
|
|
150
|
-
## Supported
|
|
152
|
+
## Supported Operations (v4.0.2+)
|
|
153
|
+
|
|
154
|
+
The `db:dump` tool supports **same-database-type backup and restore** only:
|
|
151
155
|
|
|
152
|
-
|
|
156
|
+
| Source | Target | Command | Supported |
|
|
157
|
+
|------------|------------|----------------------------------------------|-----------|
|
|
158
|
+
| SQLite | SQLite | `--format sqlite` | ✅ |
|
|
159
|
+
| MySQL | MySQL | `--from mysql --format mysql` | ✅ |
|
|
160
|
+
| PostgreSQL | PostgreSQL | `--from postgresql --format postgresql` | ✅ |
|
|
161
|
+
| SQLite | MySQL | N/A - Use JSON export/import | ❌ |
|
|
162
|
+
| SQLite | PostgreSQL | N/A - Use JSON export/import | ❌ |
|
|
163
|
+
| MySQL | PostgreSQL | N/A - Use JSON export/import | ❌ |
|
|
153
164
|
|
|
154
|
-
|
|
155
|
-
|------------|------------|-------------------------------------|
|
|
156
|
-
| SQLite | MySQL | `--format mysql` |
|
|
157
|
-
| SQLite | PostgreSQL | `--format postgresql` |
|
|
158
|
-
| MySQL | SQLite | `--from mysql --format sqlite` |
|
|
159
|
-
| PostgreSQL | SQLite | `--from postgresql --format sqlite` |
|
|
160
|
-
| MySQL | PostgreSQL | `--from mysql --format postgresql` |
|
|
161
|
-
| PostgreSQL | MySQL | `--from postgresql --format mysql` |
|
|
165
|
+
**For cross-database migrations**, see [DATA_EXPORT_IMPORT.md](DATA_EXPORT_IMPORT.md).
|
|
162
166
|
|
|
163
167
|
---
|
|
164
168
|
|