check non empty db during setup
This commit is contained in:
parent
d797045a34
commit
ab98f3b6f8
1 changed files with 8 additions and 5 deletions
|
@ -18,15 +18,18 @@ module.exports = {
|
||||||
consola.info(`Save configuration into ${config_path}`)
|
consola.info(`Save configuration into ${config_path}`)
|
||||||
fs.writeFileSync(config_path, JSON.stringify(config, null, 2))
|
fs.writeFileSync(config_path, JSON.stringify(config, null, 2))
|
||||||
|
|
||||||
// sync db (TODO, check if there's something in db and ask to backup)
|
// sync db
|
||||||
const db = require('./api/models')
|
const db = require('./api/models')
|
||||||
try {
|
try {
|
||||||
consola.info(`Create tables..`)
|
await db.user.findAll()
|
||||||
await db.sequelize.sync({force: true})
|
consola.warning(`!WARNING! Non empty db!`)
|
||||||
} catch(e) {
|
return -1
|
||||||
|
} catch(e) {}
|
||||||
|
|
||||||
|
await db.sequelize.sync({force: true}).catch(e => {
|
||||||
consola.error('Error creating tables', e)
|
consola.error('Error creating tables', e)
|
||||||
return -1
|
return -1
|
||||||
}
|
})
|
||||||
|
|
||||||
// create admin user
|
// create admin user
|
||||||
consola.info('Create admin user')
|
consola.info('Create admin user')
|
||||||
|
|
Loading…
Reference in a new issue