@zerotal/orm 1.0.1 → 1.0.3
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 +8 -0
- package/README.md +7 -7
- package/package.json +3 -3
- package/src/schema/MigrationRunner.ts +9 -1
- package/src/schema/autoMigrate.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,14 @@ follows the Zerotal monorepo's unified versioning.
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [1.0.3] — 2026-08-07
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Re-released from a rebuilt repository so the build provenance resolves. The
|
|
16
|
+
1.0.2 attestation names a repository that was renamed away, which leaves the
|
|
17
|
+
signature valid but the trace back to source dangling. No code changed.
|
|
18
|
+
|
|
11
19
|
## [1.0.0] — 2026-08-05
|
|
12
20
|
|
|
13
21
|
_First public release._
|
package/README.md
CHANGED
|
@@ -102,13 +102,13 @@ import { Migration, Schema } from "@zerotal/orm";
|
|
|
102
102
|
|
|
103
103
|
export default class CreatePostsTable extends Migration {
|
|
104
104
|
async up(): Promise<void> {
|
|
105
|
-
await Schema.create("posts", (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
await Schema.create("posts", (table) => {
|
|
106
|
+
table.increments("id");
|
|
107
|
+
table.integer("user_id").index();
|
|
108
|
+
table.string("title");
|
|
109
|
+
table.text("body");
|
|
110
|
+
table.softDeletes();
|
|
111
|
+
table.timestamps();
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerotal/orm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"maturity": "stable",
|
|
6
6
|
"private": false,
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"typecheck": "tsc --noEmit"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@zerotal/core": "1.0.
|
|
34
|
-
"@zerotal/validator": "1.0.
|
|
33
|
+
"@zerotal/core": "1.0.3",
|
|
34
|
+
"@zerotal/validator": "1.0.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "^5.8.0"
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
1
3
|
import type { SQLInstance } from "../db/sql-types.ts";
|
|
2
4
|
import type { Migration } from "./Migration.ts";
|
|
3
5
|
import { MigrationError } from "../errors/MigrationError.ts";
|
|
@@ -337,7 +339,13 @@ export class MigrationRunner {
|
|
|
337
339
|
|
|
338
340
|
const entries: MigrationEntry[] = [];
|
|
339
341
|
for (const file of files) {
|
|
340
|
-
|
|
342
|
+
// Resolved to a file:// URL, not joined as a string. `database/migrations`
|
|
343
|
+
// is a perfectly ordinary way to configure this directory, and importing
|
|
344
|
+
// `database/migrations/0001_x.ts` verbatim asks the module resolver for a
|
|
345
|
+
// *package* by that name — which fails with "Cannot find module" even
|
|
346
|
+
// though `readdirSync` just listed the file. A URL also keeps Windows
|
|
347
|
+
// drive letters from being read as a protocol.
|
|
348
|
+
const fullPath = pathToFileURL(resolve(dir, file)).href;
|
|
341
349
|
// Dynamic import — each migration file must have a default export
|
|
342
350
|
const mod = (await import(fullPath)) as { default: new () => Migration };
|
|
343
351
|
const Ctor = mod.default;
|
|
@@ -57,8 +57,8 @@ export async function synchronizeSchema(options: SynchronizeOptions = {}): Promi
|
|
|
57
57
|
const diff = await SchemaDiffer.diff(ModelInspector.all());
|
|
58
58
|
|
|
59
59
|
for (const { schema } of diff.newTables) {
|
|
60
|
-
await Schema.createIfNotExists(schema.table, (
|
|
61
|
-
const table =
|
|
60
|
+
await Schema.createIfNotExists(schema.table, (blueprint) => {
|
|
61
|
+
const table = blueprint as unknown as TableBuilder;
|
|
62
62
|
table.increments(columnDbName(schema.primaryKey));
|
|
63
63
|
for (const col of schema.columns) {
|
|
64
64
|
if (col.primary) continue; // increments() covers the PK
|
|
@@ -76,8 +76,8 @@ export async function synchronizeSchema(options: SynchronizeOptions = {}): Promi
|
|
|
76
76
|
byTable.set(nc.table, bucket);
|
|
77
77
|
}
|
|
78
78
|
for (const [table, cols] of byTable) {
|
|
79
|
-
await Schema.table(table, (
|
|
80
|
-
const tb =
|
|
79
|
+
await Schema.table(table, (blueprint) => {
|
|
80
|
+
const tb = blueprint as unknown as TableBuilder;
|
|
81
81
|
for (const col of cols) applyColumn(tb, col);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -94,8 +94,8 @@ export async function synchronizeSchema(options: SynchronizeOptions = {}): Promi
|
|
|
94
94
|
console.warn(
|
|
95
95
|
`[Zerotal] synchronize (disruptive): dropping ${table}.{${names.join(", ")}} - data will be lost.`,
|
|
96
96
|
);
|
|
97
|
-
await Schema.table(table, (
|
|
98
|
-
(
|
|
97
|
+
await Schema.table(table, (blueprint) => {
|
|
98
|
+
(blueprint as unknown as TableBuilder).dropColumn(...names);
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
}
|