aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrator.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrator.ts')
-rw-r--r--server/initializers/migrator.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts
index 379d43af5..d72c60638 100644
--- a/server/initializers/migrator.ts
+++ b/server/initializers/migrator.ts
@@ -8,7 +8,7 @@ import { LAST_MIGRATION_VERSION } from './constants'
8import { logger } from '../helpers' 8import { logger } from '../helpers'
9import { ApplicationInstance } from '../models' 9import { ApplicationInstance } from '../models'
10 10
11function migrate (finalCallback) { 11function migrate (finalCallback: (err: Error) => void) {
12 waterfall([ 12 waterfall([
13 13
14 function checkApplicationTableExists (callback) { 14 function checkApplicationTableExists (callback) {
@@ -56,7 +56,7 @@ function migrate (finalCallback) {
56 }, 56 },
57 57
58 function doMigrations (actualVersion, migrationScripts, callback) { 58 function doMigrations (actualVersion, migrationScripts, callback) {
59 eachSeries(migrationScripts, function (entity, callbackEach) { 59 eachSeries(migrationScripts, function (entity: any, callbackEach) {
60 executeMigration(actualVersion, entity, callbackEach) 60 executeMigration(actualVersion, entity, callbackEach)
61 }, function (err) { 61 }, function (err) {
62 if (err) return callback(err) 62 if (err) return callback(err)
@@ -76,7 +76,8 @@ export {
76 76
77// --------------------------------------------------------------------------- 77// ---------------------------------------------------------------------------
78 78
79function getMigrationScripts (callback) { 79type GetMigrationScriptsCallback = (err: Error, filesToMigrate?: { version: string, script: string }[]) => void
80function getMigrationScripts (callback: GetMigrationScriptsCallback) {
80 fs.readdir(path.join(__dirname, 'migrations'), function (err, files) { 81 fs.readdir(path.join(__dirname, 'migrations'), function (err, files) {
81 if (err) return callback(err) 82 if (err) return callback(err)
82 83
@@ -95,7 +96,7 @@ function getMigrationScripts (callback) {
95 }) 96 })
96} 97}
97 98
98function executeMigration (actualVersion, entity, callback) { 99function executeMigration (actualVersion: number, entity: { version: string, script: string }, callback: (err: Error) => void) {
99 const versionScript = parseInt(entity.version, 10) 100 const versionScript = parseInt(entity.version, 10)
100 101
101 // Do not execute old migration scripts 102 // Do not execute old migration scripts