@carllee1983/dbcli 0.5.2-beta → 1.2.0

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 CHANGED
@@ -5,6 +5,133 @@ All notable changes to dbcli are documented here.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.0] - 2026-03-31
9
+
10
+ ### Added
11
+
12
+ - **Multi-connection Support (v2)**: Support for multiple named database connections in a single project.
13
+ - New `dbcli use` command to switch between connections.
14
+ - Named connections with custom `.env` files via `init --conn-name` and `--env-file`.
15
+ - Global `--use <name>` flag to execute commands against a specific connection.
16
+ - **Unified DDL Interface (`migrate`)**: Abstracted DDL operations that work across PostgreSQL, MySQL, and MariaDB.
17
+ - 12 subcommands for managing tables, columns, indexes, and constraints.
18
+ - Intelligent SQL generation per database dialect.
19
+ - Default dry-run mode for safety.
20
+ - **Enhanced Data Health Checks**: Added `rowCount` and `size` checks to the `dbcli check` command.
21
+ - **Comprehensive Documentation**: Updated README (en/zh-TW) with Internals & Strategy sections and new command references.
22
+
23
+ ### Changed
24
+
25
+ - **Schema Update Strategy**: Refined how and when the schema snapshot in `.dbcli` is updated.
26
+ - Automatic snapshot refresh after successful `migrate` operations.
27
+ - Real-time schema fetching for data modification commands without affecting the snapshot.
28
+
29
+ ---
30
+
31
+ ## [1.1.0] - 2026-03-30
32
+
33
+ ### Changed
34
+
35
+ - **Adapter `execute()` 回傳型別重構**: 從 `T[]` 改為 `ExecutionResult<T>`,包含 `rows`、`affectedRows`、`lastInsertId` 欄位,DML 操作(INSERT/UPDATE/DELETE)現在回傳正確的 affected rows 計數
36
+ - **Export 覆寫確認**: `export --output` 寫入已存在檔案時會提示確認,可用 `--force` 跳過
37
+ - **`ExecutionResult<T>` 介面**: 新增統一的查詢結果型別定義於 `src/adapters/types.ts`
38
+
39
+ ---
40
+
41
+ ## [1.0.0] - 2026-03-28
42
+
43
+ ### Stable Release
44
+
45
+ dbcli v1.0.0 is the first stable release. All three milestones are complete:
46
+ - **M1 (v0.6.0):** Smart REPL — interactive shell with SQL + dbcli commands
47
+ - **M2 (v0.8.0):** Schema DDL — CREATE/DROP/ALTER TABLE, INDEX, CONSTRAINT, ENUM
48
+ - **M3 (v1.0.0):** Stabilization — documentation, permission matrix, known limitations update
49
+
50
+ ### Added
51
+
52
+ - **`dbcli migrate` command group** (12 subcommands): Full DDL operations with cross-database support
53
+ - `migrate create <table>` — CREATE TABLE with `--column` spec format (`"id:serial:pk"`)
54
+ - `migrate drop <table>` — DROP TABLE with double confirmation (`--execute --force`)
55
+ - `migrate add-column` / `drop-column` / `alter-column` — Column management
56
+ - `migrate add-index` / `drop-index` — Index management (MySQL `--table` option for DROP)
57
+ - `migrate add-constraint` / `drop-constraint` — FK, UNIQUE, CHECK constraints
58
+ - `migrate add-enum` / `alter-enum` / `drop-enum` — PostgreSQL native ENUM support
59
+ - **DDLGenerator interface** with PostgreSQL and MySQL/MariaDB dialect implementations
60
+ - PostgreSQL: SERIAL, native ENUM types, ALTER COLUMN TYPE, double-quote identifiers
61
+ - MySQL: AUTO_INCREMENT, inline ENUM, MODIFY COLUMN, backtick identifiers
62
+ - **DDLExecutor**: Unified execution pipeline — admin permission check → blacklist protection → SQL generation → dry-run/execute → schema cache auto-refresh
63
+ - **Default dry-run for DDL**: All `migrate` commands preview SQL without `--execute`. Destructive operations also require `--force`
64
+ - **142 new tests**: column-parser (17), PG DDL (35), MySQL DDL (25), factory (5), DDL executor (22), schema cache DDL (6), CLI migrate (26), live-db migrate lifecycle (6)
65
+
66
+ ### Fixed
67
+
68
+ - **Schema comment encoding**: Fixed double-encoded UTF-8 comments from MySQL/MariaDB `information_schema` (e.g., `帳號` → `帳號`)
69
+ - **MySQL connection charset**: Added `charset: utf8mb4` and `SET NAMES utf8mb4`
70
+ - **DDL multi-line SQL execution**: Fixed statement splitting to use `;\n` instead of `\n`
71
+ - **MySQL DROP INDEX**: Added `--table` option (MariaDB requires `ON <table>`)
72
+
73
+ ### Changed
74
+
75
+ - **Permission model**: 4 levels — query-only, read-write, data-admin, admin (DDL requires admin)
76
+ - **Known Limitations**: Removed "Read-only schema" and "CLI-only" (both resolved). Added "No migration version tracking" as post-v1.0 item
77
+ - **Test infrastructure**: `docker-compose.test.yml` for MySQL 8 + PostgreSQL 16 integration testing
78
+ - **Package scripts**: Added `test:unit`, `test:integration`, `test:docker`
79
+ - **SKILL.md**: Updated with full `migrate` command reference and AI agent guidelines
80
+
81
+ ### Test Results (v1.0.0)
82
+
83
+ - Unit/Core: 1082 pass, 0 fail
84
+ - Live DB (MariaDB 10.11): 61 pass
85
+ - Docker Adapter (MySQL 8 + PG 16): 18 pass
86
+
87
+ ---
88
+
89
+ ## [0.6.1-beta] - 2026-03-28
90
+
91
+ ### Encoding Fix & Test Infrastructure
92
+
93
+ ### Fixed
94
+
95
+ - **Schema comment encoding**: Fixed double-encoded UTF-8 comments from MySQL/MariaDB `information_schema`. Comments stored through latin1 (cp1252) connections now correctly display CJK characters (e.g., `帳號` → `帳號`)
96
+ - **MySQL connection charset**: Added `charset: utf8mb4` and `SET NAMES utf8mb4` to MySQL adapter connections
97
+
98
+ ### Added
99
+
100
+ - **`fixDoubleEncodedUtf8()` utility** (`src/utils/encoding.ts`): Detects and reverses cp1252-to-UTF-8 double encoding with full cp1252 reverse mapping table. Applied to schema comments in both MySQL and PostgreSQL adapters
101
+ - **`docker-compose.test.yml`**: MySQL 8.4 (port 3307) + PostgreSQL 16 (port 5433) for integration testing, with health checks and tmpfs for fast ephemeral storage
102
+ - **Environment-driven adapter tests**: `mysql.test.ts` and `postgresql.test.ts` now read connection from `MYSQL_*` / `PG_*` env vars, falling back to docker-compose defaults. Auto-skip when DB is unreachable
103
+ - **`live-db.test.ts`**: 55 comprehensive CLI-level integration tests covering all commands against live MariaDB — list, schema, query, blacklist CRUD, insert/update/delete lifecycle, export, check, diff, status, doctor, shell, format validation, SQL injection protection
104
+ - **New test scripts**: `test:unit`, `test:integration`, `test:docker` in package.json
105
+
106
+ ### Test Results
107
+
108
+ - Unit/Core: 940 pass
109
+ - Live DB (MariaDB 10.11): 55 pass
110
+ - Adapter (Docker MySQL 8 + PG 16): 18 pass
111
+
112
+ ---
113
+
114
+ ## [0.6.0-beta] - 2026-03-28
115
+
116
+ ### Interactive Shell — Smart REPL
117
+
118
+ ### Added
119
+
120
+ - **`dbcli shell` command:** Interactive database shell with SQL execution and dbcli command dispatch
121
+ - **SQL-only mode:** `--sql` flag restricts to SQL statements only
122
+ - **Auto-completion (Tab):** Context-aware completion for SQL keywords, table names, column names, and dbcli commands
123
+ - **Multi-line SQL:** Accumulates input until `;` is found, with `...>` continuation prompt
124
+ - **SQL syntax highlighting:** Real-time colorization of keywords, strings, and numbers in verbose mode
125
+ - **Meta commands:** `.help`, `.quit`/`.exit`, `.clear`, `.format`, `.history`, `.timing`
126
+ - **Persistent history:** Stored in `~/.dbcli_history` (max 1000 entries), with up/down navigation and Ctrl+R search
127
+ - **Permission & blacklist integration:** Full enforcement within REPL session — SQL goes through PermissionGuard, query results go through blacklist filtering
128
+ - **Auto-reconnect:** Attempts to reconnect once on connection errors, then displays error without crashing the session
129
+ - **Error resilience:** SQL/permission/connection errors never crash the session
130
+ - **i18n support:** All shell messages available in English and Traditional Chinese
131
+ - **102 new tests:** input-classifier (25), multiline-buffer (10), meta-commands (15), completer (17), history-manager (8), command-dispatcher (12), repl-engine (12), shell-command (3)
132
+
133
+ ---
134
+
8
135
  ## [0.5.2-beta] - 2026-03-27
9
136
 
10
137
  ### Fixed
@@ -264,12 +391,11 @@ dbcli v0.1.0-beta is a complete, production-ready CLI tool enabling AI agents an
264
391
 
265
392
  ---
266
393
 
267
- ## Known Limitations (V1)
394
+ ## Known Limitations
268
395
 
269
- - **Single database per project:** Multi-connection support deferred to a future version
270
- - **No audit logging:** WHO/WHAT/WHEN tracking deferred to a future version
271
- - **Read-only schema:** No schema modification commands (ALTER TABLE, etc.) in V1
272
- - **CLI-only:** No visual schema designer, REPL, or interactive shell in V1
396
+ - **Single database per project:** Each directory uses one `.dbcli` config. For multi-database setups, use separate directories or `--config` flag. This is by design, not a technical limitation.
397
+ - **No audit logging:** WHO/WHAT/WHEN tracking deferred to post-v1.0
398
+ - **No migration version tracking:** `migrate` commands execute DDL directly without version history or rollback. The `migrate` namespace is reserved for future migration tracking support.
273
399
 
274
400
  ---
275
401