chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 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