diff options
author | David Mehren | 2021-02-27 21:33:05 +0100 |
---|---|---|
committer | David Mehren | 2021-02-27 21:33:05 +0100 |
commit | 0db862f3c9318f3e214d6b09604760a9844dcfd5 (patch) | |
tree | 4db476be820a6cd94136f238c693221c4d6db1d5 /app.js | |
parent | 6186e0f48f3414e9de4ab5f864c2d153aa995c51 (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 'app.js')
-rw-r--r-- | app.js | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -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 |