fix migration so it doesn't error out on existing devices
This commit is contained in:
parent
2b3e49fdab
commit
d3c2448a12
2 changed files with 29 additions and 5 deletions
|
|
@ -1,12 +1,20 @@
|
|||
const db = require('./db')
|
||||
const migrateTools = require('./migrate-tools')
|
||||
|
||||
exports.up = function (next) {
|
||||
const sql = [
|
||||
'alter table devices add column name text not null'
|
||||
]
|
||||
db.multi(sql, 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)
|
||||
})
|
||||
}
|
||||
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
const sql = ['alter table devices drop column name']
|
||||
db.multi(sql, next)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue