wait for db on firstrun and prefill notifications with migrations
This commit is contained in:
parent
abde1be657
commit
a3624eb60d
3 changed files with 1872 additions and 1984 deletions
|
@ -34,8 +34,9 @@ module.exports = {
|
|||
consola.warn(` ⚠️ ${e}. You can specify configuration path using '--config'`)
|
||||
}
|
||||
|
||||
// sync db
|
||||
const db = require('./api/models')
|
||||
await db.authenticate()
|
||||
|
||||
const users = await db.user.findAll()
|
||||
if (users.length) {
|
||||
consola.warn(' ⚠ Non empty db! Please move your current db elsewhere than retry.')
|
||||
|
|
20
server/migrations/20201103161446-notification_queue.js
Normal file
20
server/migrations/20201103161446-notification_queue.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkInsert('notifications', [
|
||||
|
||||
// send AP message
|
||||
{ action: 'Create', type: 'ap', filters: '{ is_visible: true }', createdAt: new Date(), updatedAt: new Date() },
|
||||
{ action: 'Update', type: 'ap', filters: '{ is_visible: true }', createdAt: new Date(), updatedAt: new Date() },
|
||||
{ action: 'Delete', type: 'ap', filters: '{ is_visible: true }', createdAt: new Date(), updatedAt: new Date() },
|
||||
|
||||
// send anon event to admin
|
||||
{ action: 'Create', type: 'admin_email', filters: '{ is_visible: false }', createdAt: new Date(), updatedAt: new Date() }
|
||||
]).catch(e => { })
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkDelete('notification')
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue