@zerotal/orm 1.6.3 → 1.7.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 +40 -1
- package/api-surface.md +1665 -0
- package/package.json +4 -3
- package/src/commands/MigrateCommand.ts +14 -0
- package/src/db/DB.ts +25 -0
- package/src/db/dialects/MysqlDialect.ts +4 -0
- package/src/db/dialects/PostgresDialect.ts +3 -0
- package/src/db/dialects/SqliteDialect.ts +4 -0
- package/src/db/dialects/types.ts +17 -0
- package/src/observability.ts +75 -1
- package/src/schema/MigrationRunner.ts +90 -14
- package/src/schema/Schema.ts +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,46 @@ follows the Zerotal monorepo's unified versioning.
|
|
|
6
6
|
|
|
7
7
|
**Maturity: `stable`**
|
|
8
8
|
|
|
9
|
-
## [
|
|
9
|
+
## [1.7.0] — 2026-08-16
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Migrations are now actually transactional.** The runner wrapped each `up()` in
|
|
14
|
+
`begin()` and the docblock promised all-or-nothing, but the wrapper governed nothing:
|
|
15
|
+
`Schema` resolved the _global_ connection, so the migration's DDL ran on a pooled
|
|
16
|
+
connection and committed independently of the transaction around it. On PostgreSQL a
|
|
17
|
+
migration that failed on its third statement left the first two behind, and the enclosing
|
|
18
|
+
`ROLLBACK` had nothing to undo.
|
|
19
|
+
|
|
20
|
+
Three changes close it. `Schema` resolves the enclosing transaction when there is one
|
|
21
|
+
(new `_getScopedDbConnection`), so DDL issued inside `DB.transaction()` joins it —
|
|
22
|
+
migrations included. The tracking-table insert moved _inside_ the transaction, because
|
|
23
|
+
recording after the commit leaves a window where the schema has moved and nothing says so,
|
|
24
|
+
and the next deploy re-runs the migration against a schema it already changed. And
|
|
25
|
+
rollback got the same treatment: a `down()` that fails part-way now undoes nothing rather
|
|
26
|
+
than leaving the schema and the tracking table disagreeing.
|
|
27
|
+
|
|
28
|
+
This was invisible to the test suite by construction — `new SQL(":memory:")` is a single
|
|
29
|
+
handle, so the "global" and transaction connections are the same object and DDL joined the
|
|
30
|
+
transaction by accident. The new tests use a fake that keeps them distinguishable.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- **`MigrationRunner.willRollBackOnFailure`** and `SqlDialect.supportsTransactionalDdl`.
|
|
35
|
+
MySQL and MariaDB implicitly commit on every DDL statement, so a transaction around a
|
|
36
|
+
migration there is a promise that cannot be kept — the runner no longer opens one, and
|
|
37
|
+
`bun zt migrate` warns before it starts rather than after something breaks. PostgreSQL
|
|
38
|
+
and SQLite report `true`.
|
|
39
|
+
|
|
40
|
+
- **Two DevTools tabs the ORM already had the data for.** `ModelChanged`,
|
|
41
|
+
`TransactionCommitted` and `TransactionRolledBack` were on the framework event bus and went
|
|
42
|
+
nowhere: a request that wrote four rows and one that wrote none looked identical in the
|
|
43
|
+
panel, and a transaction that rolled back showed only as queries that appeared to succeed.
|
|
44
|
+
|
|
45
|
+
The observability bridge now declares a **Models** channel (grouped per model) and a
|
|
46
|
+
**Transactions** channel (marking a rollback as a warning, with its reason). Both are
|
|
47
|
+
declared as data, so DevTools ships no ORM-specific code — and both are skipped entirely
|
|
48
|
+
when DevTools is not installed, as every other bridge here is.
|
|
10
49
|
|
|
11
50
|
## [1.6.0] — 2026-08-15
|
|
12
51
|
|