Comparing version
@@ -9,2 +9,5 @@ export var Action; | ||
})(Action || (Action = {})); | ||
function sleep(time = 1) { | ||
return new Promise(resolve => setTimeout(resolve, time)); | ||
} | ||
export class Process { | ||
@@ -56,2 +59,3 @@ constructor(db, state) { | ||
for (const item of actions) { | ||
await sleep(100); // Skip some time for exec date gap | ||
try { | ||
@@ -90,5 +94,5 @@ switch (item.action) { | ||
await db.q(migration.sql.do); | ||
await db.q(` | ||
INSERT INTO ${this.state.tableName} (name, do_sql, do_hash, undo_sql, undo_hash) | ||
VALUES ($1, $2, $3, $4, $5) | ||
await db.q(/*sql*/ ` | ||
INSERT INTO ${this.state.tableName} (name, do_sql, do_hash, undo_sql, undo_hash, exec_date) | ||
VALUES ($1, $2, $3, $4, $5, $6) | ||
`, [ | ||
@@ -98,2 +102,3 @@ name, | ||
migration.undo.sql, migration.undo.hash, | ||
new Date(), | ||
]); | ||
@@ -108,3 +113,3 @@ } | ||
await db.q(migration.sql.do); | ||
await db.q(` | ||
await db.q(/*sql*/ ` | ||
UPDATE ${this.state.tableName} | ||
@@ -116,3 +121,3 @@ SET | ||
undo_hash = $5, | ||
exec_date = now() | ||
exec_date = $6 | ||
WHERE name = $1 | ||
@@ -123,2 +128,3 @@ `, [ | ||
migration.undo.sql, migration.undo.hash, | ||
new Date(), | ||
]); | ||
@@ -125,0 +131,0 @@ } |
@@ -84,3 +84,3 @@ import path from 'node:path'; | ||
`); | ||
const result = await this.db.r(`SELECT * FROM ${this.tableName} ORDER BY exec_date`); | ||
const result = await this.db.r(/*sql*/ `SELECT * FROM ${this.tableName} ORDER BY exec_date`); | ||
this.table = result.map(item => { | ||
@@ -87,0 +87,0 @@ return new Migration(item.name, item.do_sql, item.undo_sql, item.do_hash, item.undo_hash); |
{ | ||
"name": "do-migrate", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "PostgreSQL migrator", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
-100%67476
-90.47%42
-53.33%1197
-50.58%