summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorDavid Mehren2021-02-27 21:33:05 +0100
committerDavid Mehren2021-02-27 21:33:05 +0100
commit0db862f3c9318f3e214d6b09604760a9844dcfd5 (patch)
tree4db476be820a6cd94136f238c693221c4d6db1d5 /app.js
parent6186e0f48f3414e9de4ab5f864c2d153aa995c51 (diff)
Run database migrations automatically on startup
This commit removes the need for separate migrations with the sequelize-cli by running them with umzug on application startup. This is a port of #384 Co-authored-by: Sheogorath <sheogorath@shivering-isles.com> Signed-off-by: David Mehren <git@herrmehren.de>
Diffstat (limited to '')
-rw-r--r--app.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/app.js b/app.js
index ae332d98..ce37032b 100644
--- a/app.js
+++ b/app.js
@@ -264,16 +264,19 @@ function startListen () {
}
// sync db then start listen
-models.sequelize.sync().then(function () {
- // check if realtime is ready
- if (realtime.isReady()) {
- models.Revision.checkAllNotesRevision(function (err, notes) {
- if (err) throw new Error(err)
- if (!notes || notes.length <= 0) return startListen()
- })
- } else {
- throw new Error('server still not ready after db synced')
- }
+models.sequelize.authenticate().then(function () {
+ models.runMigrations().then(() => {
+ sessionStore.sync()
+ // check if realtime is ready
+ if (realtime.isReady()) {
+ models.Revision.checkAllNotesRevision(function (err, notes) {
+ if (err) throw new Error(err)
+ if (!notes || notes.length <= 0) return startListen()
+ })
+ } else {
+ throw new Error('server still not ready after db synced')
+ }
+ })
})
// log uncaught exception