v12.0.0 - initial commit
This commit is contained in:
commit
e2c49ea43c
1145 changed files with 97211 additions and 0 deletions
23
packages/server/lib/db-migrate-store.js
Normal file
23
packages/server/lib/db-migrate-store.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
const db = require('../lib/db')
|
||||
const logger = require('./logger')
|
||||
|
||||
const upsert =
|
||||
'insert into migrations (id, data) values (1, $1) on conflict (id) do update set data = $1'
|
||||
|
||||
function DbMigrateStore() {}
|
||||
|
||||
DbMigrateStore.prototype.save = function (set, fn) {
|
||||
let insertData = JSON.stringify({
|
||||
lastRun: set.lastRun,
|
||||
migrations: set.migrations,
|
||||
})
|
||||
db.none(upsert, [insertData]).then(fn).catch(logger.error)
|
||||
}
|
||||
|
||||
DbMigrateStore.prototype.load = function (fn) {
|
||||
db.oneOrNone('select data from migrations').then(res => {
|
||||
fn(null, res?.data || {})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = DbMigrateStore
|
||||
Loading…
Add table
Add a link
Reference in a new issue