peta-migrate 0.2.0 → 0.2.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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 zfadhli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createMigrationGenerator, c as loadConfig, d as computeChecksum, f as loadChecksums, i as createMigrationRunner, l as loadMigrationFiles, m as verifyChecksum, n as loadSnapshot, o as diffSnapshots, p as saveChecksums, r as saveSnapshot, t as createSnapshot, u as loadModels } from "./snapshot-
|
|
1
|
+
import { a as createMigrationGenerator, c as loadConfig, d as computeChecksum, f as loadChecksums, i as createMigrationRunner, l as loadMigrationFiles, m as verifyChecksum, n as loadSnapshot, o as diffSnapshots, p as saveChecksums, r as saveSnapshot, t as createSnapshot, u as loadModels } from "./snapshot-CO180dF3.mjs";
|
|
2
2
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import cac from "cac";
|
|
@@ -145,7 +145,7 @@ async function run() {
|
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
spinner.text = "Pushing schema to database...";
|
|
148
|
-
const { pushSchema } = await import("./pusher-
|
|
148
|
+
const { pushSchema } = await import("./pusher-Be3BYUQM.mjs").then((n) => n.n);
|
|
149
149
|
const created = await pushSchema(config.getKysely(), models);
|
|
150
150
|
await saveSnapshot(resolve(config.migrationsDir, "snapshot.json"), createSnapshot(models));
|
|
151
151
|
if (created.length === 0) spinner.succeed("Schema is up to date (no new tables).");
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as pushSchema } from "./pusher-
|
|
2
|
-
import { a as createMigrationGenerator, c as loadConfig, d as computeChecksum, f as loadChecksums, i as createMigrationRunner, l as loadMigrationFiles, m as verifyChecksum, n as loadSnapshot, o as diffSnapshots, p as saveChecksums, r as saveSnapshot, s as defineConfig, t as createSnapshot, u as loadModels } from "./snapshot-
|
|
1
|
+
import { t as pushSchema } from "./pusher-Be3BYUQM.mjs";
|
|
2
|
+
import { a as createMigrationGenerator, c as loadConfig, d as computeChecksum, f as loadChecksums, i as createMigrationRunner, l as loadMigrationFiles, m as verifyChecksum, n as loadSnapshot, o as diffSnapshots, p as saveChecksums, r as saveSnapshot, s as defineConfig, t as createSnapshot, u as loadModels } from "./snapshot-CO180dF3.mjs";
|
|
3
3
|
export { computeChecksum, createMigrationGenerator, createMigrationRunner, createSnapshot, defineConfig, diffSnapshots, loadChecksums, loadConfig, loadMigrationFiles, loadModels, loadSnapshot, pushSchema, saveChecksums, saveSnapshot, verifyChecksum };
|
|
@@ -22,9 +22,9 @@ async function pushSchema(db, models) {
|
|
|
22
22
|
for (const [, model] of models) {
|
|
23
23
|
if (!model.table) continue;
|
|
24
24
|
if (await tableExists(db, model.table)) continue;
|
|
25
|
-
|
|
25
|
+
let qb = db.schema.createTable(model.table).ifNotExists();
|
|
26
26
|
const columns = model.columns;
|
|
27
|
-
for (const [name, col] of Object.entries(columns)) qb.addColumn(name, mapPushType(col), (cb) => buildColumn(col, cb));
|
|
27
|
+
for (const [name, col] of Object.entries(columns)) qb = qb.addColumn(name, mapPushType(col), (cb) => buildColumn(col, cb));
|
|
28
28
|
await qb.execute();
|
|
29
29
|
createdTables.push(model.table);
|
|
30
30
|
for (const [colName, col] of Object.entries(columns)) if (col.hasConstraint("index") && !col.isPrimaryKey && !col.isUnique) await db.schema.createIndex(`${model.table}_${colName}_index`).on(model.table).column(colName).execute();
|
|
@@ -411,11 +411,7 @@ function createMigrationRunner(db, table = "_peta_migrations") {
|
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
async function ensureTable() {
|
|
414
|
-
|
|
415
|
-
if (result.error) {
|
|
416
|
-
const msg = result.error.message ?? "";
|
|
417
|
-
if (!msg.includes("no migrations") && !msg.includes("no pending")) throw result.error;
|
|
418
|
-
}
|
|
414
|
+
await db.schema.createTable(table).addColumn("name", "varchar(255)", (cb) => cb.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (cb) => cb.notNull()).ifNotExists().execute();
|
|
419
415
|
}
|
|
420
416
|
async function getCompleted() {
|
|
421
417
|
return queryCompleted();
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peta-migrate",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"
|
|
4
|
+
"private": false,
|
|
5
|
+
"version": "0.2.2",
|
|
5
6
|
"description": "Migration tools for peta-orm",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "git+https://github.com/zfadhli/peta-stack.git"
|
|
10
11
|
},
|
|
11
|
-
"module": "
|
|
12
|
+
"module": "./dist/index.mjs",
|
|
12
13
|
"main": "./dist/index.mjs",
|
|
13
14
|
"types": "./dist/index.d.mts",
|
|
14
15
|
"exports": {
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"build": "tsdown",
|
|
49
|
-
"
|
|
50
|
+
"prepublishOnly": "bun run build",
|
|
50
51
|
"typecheck": "bun x tsc --noEmit",
|
|
51
52
|
"test": "bun test"
|
|
52
53
|
}
|