ts-grm-migrate 0.1.0-alpha.3 → 0.1.0-alpha.5
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 +5 -0
- package/README.md +21 -3
- package/THIRD_PARTY_NOTICES.md +6 -0
- package/dist/bin.mjs +2 -2
- package/dist/bin.mjs.map +1 -1
- package/dist/{cli-CMBM5t1z.mjs → cli-Cfr6e9vX.mjs} +1390 -493
- package/dist/cli-Cfr6e9vX.mjs.map +1 -0
- package/dist/index.d.mts +74 -11
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/docs/design.md +1 -1
- package/docs/migrations.md +6 -2
- package/docs/zh-CN/CHANGELOG.md +5 -0
- package/docs/zh-CN/README.md +21 -3
- package/docs/zh-CN/THIRD_PARTY_NOTICES.md +6 -0
- package/docs/zh-CN/design.md +1 -1
- package/docs/zh-CN/migrations.md +6 -2
- package/package.json +6 -2
- package/dist/cli-CMBM5t1z.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](docs/zh-CN/CHANGELOG.md)
|
|
4
4
|
|
|
5
|
+
## 0.1.0-alpha.4 (pending publication)
|
|
6
|
+
|
|
7
|
+
- Localize configuration, history, locking, DDL, transaction and drift explanations throughout the CLI; preserve technical identifiers and expose original external diagnostics with `--detail`.
|
|
8
|
+
- Explain model naming errors in the selected language and restrict ESM troubleshooting hints to module-format failures.
|
|
9
|
+
|
|
5
10
|
## 0.1.0-alpha.1 (pending publication)
|
|
6
11
|
|
|
7
12
|
- Add `dev --create-only` and read-only `check`, validate history before development generation, preserve unmanaged indexes, order PostgreSQL dependencies, and handle MySQL identity/default changes together.
|
package/README.md
CHANGED
|
@@ -35,6 +35,14 @@ npm install -D ts-grm-migrate@next
|
|
|
35
35
|
- `@next` follows prereleases. Pin an exact version when reproducibility matters, for example `ts-grm-migrate@0.1.0-alpha.0`.
|
|
36
36
|
- Run the installed CLI with `npx tgm`, or use `tgm` / `ts-grm-migrate` through your package manager.
|
|
37
37
|
|
|
38
|
+
In a workspace with non-hoisted dependencies (for example a Bun installation), npm's workspace lookup may miss the child's local CLI or select a different version installed at the root. From the child project, use:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx --workspaces=false tgm dev --create-only -n init
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This keeps npm's lookup in the current project. If npm reports `No versions available for tgm`, it has failed to locate the local executable and is looking for a package named `tgm`; the package to install is `ts-grm-migrate`. Check that `node_modules/.bin/tgm` resolves to an existing `dist/bin.mjs`, and reinstall dependencies with the project's package manager if the link is broken. The CLI cannot repair npm's command resolution because it has not started yet. [npm exec workspace behavior](https://docs.npmjs.com/cli/npm-exec/).
|
|
45
|
+
|
|
38
46
|
## Quick start
|
|
39
47
|
|
|
40
48
|
> **Your project must use ESM.** Set `"type": "module"` in `package.json`. The ts-grm model registry is a module-level singleton; the migration tool and your models must share the same ESM instance. CommonJS models may register with a separate instance and be invisible to the migration tool.
|
|
@@ -213,7 +221,7 @@ You can also run `tests/server-integration.test.ts` against dedicated instances
|
|
|
213
221
|
| `tgm resolve --applied <id>` | Mark SQL already executed manually as applied |
|
|
214
222
|
| `tgm resolve --rolled-back <id>` | Mark an attempt as rolled back so it becomes pending again |
|
|
215
223
|
|
|
216
|
-
Options: `--create-only` generates without applying (`dev` only); `--config <path>` selects a configuration file; `-n` / `--name <name>` names a migration; `--force` skips destructive-change confirmation; `--detail` shows execution steps, SQL, and locks; `--lang <en|zh-CN>` selects the language for this command; `-h` shows help.
|
|
224
|
+
Options: `--dry-run` previews SQL without applying it (`push` only); `--create-only` generates without applying (`dev` only); `--config <path>` selects a configuration file; `-n` / `--name <name>` names a migration; `--force` skips destructive-change confirmation; `--detail` shows execution steps, SQL, and locks; `--lang <en|zh-CN>` selects the language for this command; `-h` shows help.
|
|
217
225
|
|
|
218
226
|
Normal commands report the target, migration count or ID, and result. `status` intentionally lists migrations because it is an inspection command. For example, `tgm deploy` may print `Applied 2 migrations to postgres/app/public.` The SQL shown with `--detail` may contain business data: take care when saving or sharing logs. Diagnostic events do not print connection passwords.
|
|
219
227
|
|
|
@@ -227,7 +235,17 @@ npx tgm deploy --lang zh-CN
|
|
|
227
235
|
npx tgm status --lang zh-CN --detail
|
|
228
236
|
```
|
|
229
237
|
|
|
230
|
-
The precedence is **`--lang` > configuration `language` > `en`**. For example, `tgm deploy --lang en` uses English once in a project configured for Chinese. `--help` and unknown commands do not load the project configuration, so add `--lang zh-CN` explicitly for Chinese help or errors in those paths. `--detail` works with either language.
|
|
238
|
+
The precedence is **`--lang` > configuration `language` > `en`**. For example, `tgm deploy --lang en` uses English once in a project configured for Chinese. `--help` and unknown commands do not load the project configuration, so add `--lang zh-CN` explicitly for Chinese help or errors in those paths. `--detail` works with either language. All tool-authored explanations follow the selected language, including configuration validation, history checks, DDL limitations, locks, transaction failures and drift descriptions. SQL, identifiers, paths, commands and error codes retain their original spelling. Known upstream model errors and common driver error codes receive localized explanations. Unrecognized external errors receive a localized summary; use `--detail` to include the original diagnostic text for troubleshooting.
|
|
239
|
+
|
|
240
|
+
Model names use PascalCase, for example `model("SysUser", ...)`; a table-style name such as `sys_user` is not a valid model name. Upstream 0.0.13 accidentally prints the lowercase property-name regex in this error, although model validation requires an uppercase first letter. Model validation errors do not receive an ESM hint; only module-format failures do. Missing files or dependencies receive a path/install hint instead.
|
|
241
|
+
|
|
242
|
+
To retain the database table name `sys_user`, configure it in the fourth argument:
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
export const SYS_USER = model("SysUser", "id", class {
|
|
246
|
+
id = prop.i64();
|
|
247
|
+
}, (ctx) => ctx.table("sys_user"));
|
|
248
|
+
```
|
|
231
249
|
|
|
232
250
|
## Behavior
|
|
233
251
|
|
|
@@ -235,7 +253,7 @@ The precedence is **`--lang` > configuration `language` > `en`**. For example, `
|
|
|
235
253
|
- **Independent indexes and comments are not managed by models:** custom migration indexes are preserved while their columns remain. Explicit programmatic schemas may manage indexes; removing a unique index is flagged as destructive.
|
|
236
254
|
- **Migration files are readable SQL:** `<migrationsDir>/<timestamp>_<name>.sql` can be edited before application. **Do not edit an applied migration.** `deploy` rejects a changed checksum; make a new migration instead.
|
|
237
255
|
- **Destructive changes require confirmation:** dropping tables or columns, changing column types, and explicit unique-index removal prompt during model synchronization; non-interactive synchronization requires `--force`. `deploy` applies reviewed SQL files without confirmation.
|
|
238
|
-
- **Post-migration checks:** `dev
|
|
256
|
+
- **Post-migration checks:** `dev` and `deploy` reread the schema and warn about remaining differences. `push` returns 1 if differences remain after synchronization; cancellation also returns 1. `check` returns 1 for differences, including CHECK constraints whose equivalence cannot be proven. For example:
|
|
239
257
|
|
|
240
258
|
```text
|
|
241
259
|
Warning: postgres/app/public differs from the model:
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -13,3 +13,9 @@ The `TableDef`, `ColumnDef`, and constraint type declarations in `src/vendor/ts-
|
|
|
13
13
|
- [Full Apache-2.0 license](LICENSES/Apache-2.0.txt)
|
|
14
14
|
|
|
15
15
|
The published package keeps `@ts-grm/core` and `@ts-grm/sql` as external peer dependencies; it does not bundle upstream implementations. Database drivers are external dependencies with their own licenses.
|
|
16
|
+
|
|
17
|
+
## proper-lockfile
|
|
18
|
+
|
|
19
|
+
Atomic renewable local leases use the external MIT-licensed `proper-lockfile` package. Its dependencies retain their own licenses in their distributed packages.
|
|
20
|
+
|
|
21
|
+
- @see https://github.com/moxystudio/node-proper-lockfile
|
package/dist/bin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as run, r as messages, t as parseArgs, y as MigrationAbortedError } from "./cli-
|
|
2
|
+
import { K as formatError, n as run, r as messages, t as parseArgs, y as MigrationAbortedError } from "./cli-Cfr6e9vX.mjs";
|
|
3
3
|
//#region src/bin.ts
|
|
4
4
|
async function main() {
|
|
5
5
|
const argv = process.argv.slice(2);
|
|
@@ -15,7 +15,7 @@ async function main() {
|
|
|
15
15
|
process.exitCode = 0;
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
console.error(`${m.error}: ${e.
|
|
18
|
+
console.error(`${m.error}: ${formatError(e, language, parseArgs(argv).flags.has("detail"))}`);
|
|
19
19
|
process.exitCode = 1;
|
|
20
20
|
}
|
|
21
21
|
}
|
package/dist/bin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.mjs","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs, run } from \"./cli.js\";\nimport { messages, type CliLanguage } from \"./cli/messages.js\";\nimport { MigrationAbortedError } from \"./migrator.js\";\n\nasync function main(): Promise<void> {\n const argv = process.argv.slice(2);\n let language: CliLanguage = parseArgs(argv).flags.get(\"lang\") === \"zh-CN\" ? \"zh-CN\" : \"en\";\n try {\n process.exitCode = await run(argv, process.cwd(), { onLanguage: (selected) => { language = selected; } });\n } catch (e) {\n const m = messages(language);\n if (e instanceof MigrationAbortedError) {\n console.log(m.cancelled);\n process.exitCode = 0;\n return;\n }\n console.error(`${m.error}: ${(e
|
|
1
|
+
{"version":3,"file":"bin.mjs","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs, run } from \"./cli.js\";\nimport { messages, type CliLanguage } from \"./cli/messages.js\";\nimport { MigrationAbortedError } from \"./migrator.js\";\nimport { formatError } from \"./diagnostics/error.js\";\n\nasync function main(): Promise<void> {\n const argv = process.argv.slice(2);\n let language: CliLanguage = parseArgs(argv).flags.get(\"lang\") === \"zh-CN\" ? \"zh-CN\" : \"en\";\n try {\n process.exitCode = await run(argv, process.cwd(), { onLanguage: (selected) => { language = selected; } });\n } catch (e) {\n const m = messages(language);\n if (e instanceof MigrationAbortedError) {\n console.log(m.cancelled);\n process.exitCode = 0;\n return;\n }\n console.error(`${m.error}: ${formatError(e, language, parseArgs(argv).flags.has(\"detail\"))}`);\n process.exitCode = 1;\n }\n}\n\n// Keep the executable separate from library exports; no config/import cycle.\nvoid main();\n"],"mappings":";;;AAMA,eAAe,OAAsB;CACnC,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;CACjC,IAAI,WAAwB,UAAU,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,MAAM,UAAU,UAAU;CACtF,IAAI;EACF,QAAQ,WAAW,MAAM,IAAI,MAAM,QAAQ,IAAI,GAAG,EAAE,aAAa,aAAa;GAAE,WAAW;EAAU,EAAE,CAAC;CAC1G,SAAS,GAAG;EACV,MAAM,IAAI,SAAS,QAAQ;EAC3B,IAAI,aAAa,uBAAuB;GACtC,QAAQ,IAAI,EAAE,SAAS;GACvB,QAAQ,WAAW;GACnB;EACF;EACA,QAAQ,MAAM,GAAG,EAAE,MAAM,IAAI,YAAY,GAAG,UAAU,UAAU,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,GAAG;EAC5F,QAAQ,WAAW;CACrB;AACF;AAGK,KAAK"}
|