hanoman 0.1.1 → 0.1.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/README.md +7 -0
- package/dist/build-info.json +3 -3
- package/dist/cli.js +29 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,6 +78,13 @@ ditolak kecuali `--force`.
|
|
|
78
78
|
> berkas DB tertentu tanpa menyentuh var itu, pakai `HANOMAN_DATABASE_URL=file:/path/hanoman.db`
|
|
79
79
|
> atau `hanoman --db /path/hanoman.db`.
|
|
80
80
|
|
|
81
|
+
## Kalau `hanoman` gagal menerapkan migrasi
|
|
82
|
+
|
|
83
|
+
**`P3005 — The database schema is not empty`** berarti berkas DB itu sudah punya tabel tapi tak
|
|
84
|
+
punya riwayat migrasi hanoman — biasanya bukan DB hanoman versi ini (sisa prototipe lama, atau
|
|
85
|
+
berkas tool lain yang kebetulan bernama sama). hanoman **tidak** mengubah isinya. Pindahkan berkas
|
|
86
|
+
itu lalu jalankan ulang, atau tunjuk berkas lain dengan `hanoman --db /path/baru.db`.
|
|
87
|
+
|
|
81
88
|
## Lisensi
|
|
82
89
|
|
|
83
90
|
MIT — lihat `LICENSE`.
|
package/dist/build-info.json
CHANGED
package/dist/cli.js
CHANGED
|
@@ -256,6 +256,7 @@ __export(start_exports, {
|
|
|
256
256
|
default: () => start,
|
|
257
257
|
distDir: () => distDir,
|
|
258
258
|
ensurePrismaClient: () => ensurePrismaClient,
|
|
259
|
+
migrateFailureHint: () => migrateFailureHint,
|
|
259
260
|
parseStartArgs: () => parseStartArgs,
|
|
260
261
|
prismaClientUsable: () => prismaClientUsable
|
|
261
262
|
});
|
|
@@ -307,10 +308,29 @@ function distDir() {
|
|
|
307
308
|
}
|
|
308
309
|
function runPrisma(args, dbUrl) {
|
|
309
310
|
const prismaCli = prismaCliPath(createRequire(import.meta.url).resolve);
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
311
|
+
try {
|
|
312
|
+
const out = execFileSync(process.execPath, [prismaCli, ...args], {
|
|
313
|
+
env: { ...process.env, DATABASE_URL: dbUrl },
|
|
314
|
+
encoding: "utf8",
|
|
315
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
316
|
+
});
|
|
317
|
+
process.stdout.write(out);
|
|
318
|
+
return out;
|
|
319
|
+
} catch (e) {
|
|
320
|
+
const err = e;
|
|
321
|
+
const output = `${err.stdout ?? ""}${err.stderr ?? ""}`;
|
|
322
|
+
process.stderr.write(output);
|
|
323
|
+
throw Object.assign(new Error("prisma gagal"), { output });
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function migrateFailureHint(output, dbFile) {
|
|
327
|
+
if (!output.includes("P3005")) return null;
|
|
328
|
+
return `hanoman: berkas DB ${dbFile} sudah berisi tabel, tapi tak punya riwayat migrasi hanoman.
|
|
329
|
+
Biasanya ia bukan DB hanoman versi ini \u2014 mis. sisa prototipe lama atau berkas tool lain.
|
|
330
|
+
Pilih salah satu:
|
|
331
|
+
\u2022 Pindahkan berkas itu, lalu jalankan ulang: mv "${dbFile}" "${dbFile}.lama"
|
|
332
|
+
\u2022 Pakai berkas lain: hanoman --db /path/baru.db (atau HANOMAN_DATABASE_URL=file:/path/baru.db)
|
|
333
|
+
Isi berkas lama tidak diubah oleh hanoman \u2014 periksa dulu sebelum menghapusnya.`;
|
|
314
334
|
}
|
|
315
335
|
function applyMigrations(schema, dbUrl) {
|
|
316
336
|
runPrisma(["migrate", "deploy", "--schema", schema], dbUrl);
|
|
@@ -371,8 +391,11 @@ async function start(argv, ctx) {
|
|
|
371
391
|
`);
|
|
372
392
|
try {
|
|
373
393
|
applyMigrations(layout.schema, dbUrl);
|
|
374
|
-
} catch {
|
|
375
|
-
|
|
394
|
+
} catch (e) {
|
|
395
|
+
const hint = migrateFailureHint(String(e.output ?? ""), dbFilePath(dbUrl));
|
|
396
|
+
ctx.stderr(hint ? `
|
|
397
|
+
${hint}
|
|
398
|
+
` : "hanoman: `prisma migrate deploy` gagal \u2014 lihat keluaran di atas\n");
|
|
376
399
|
return 1;
|
|
377
400
|
}
|
|
378
401
|
}
|