* Revert "Migration sql changes (#199)"
This reverts commit 12c834469c.
* Save migrate file on db
* Add message on migration error in lamassu-update
28 lines
686 B
JavaScript
28 lines
686 B
JavaScript
const db = require('./db')
|
|
const migrateTools = require('./migrate-tools')
|
|
|
|
exports.up = function (next) {
|
|
return migrateTools.migrateNames()
|
|
.then(updateSql => {
|
|
const sql = [
|
|
'alter table devices add column name text',
|
|
updateSql,
|
|
'alter table devices alter column name set not null'
|
|
]
|
|
|
|
return db.multi(sql, next)
|
|
})
|
|
.catch(() => {
|
|
const sql = [
|
|
'alter table devices add column name text',
|
|
'alter table devices alter column name set not null'
|
|
]
|
|
|
|
return db.multi(sql, next)
|
|
})
|
|
}
|
|
|
|
exports.down = function (next) {
|
|
const sql = ['alter table devices drop column name']
|
|
db.multi(sql, next)
|
|
}
|