diff options
Diffstat (limited to 'server/initializers/migrator.ts')
-rw-r--r-- | server/initializers/migrator.ts | 9 |
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' | |||
8 | import { logger } from '../helpers' | 8 | import { logger } from '../helpers' |
9 | import { ApplicationInstance } from '../models' | 9 | import { ApplicationInstance } from '../models' |
10 | 10 | ||
11 | function migrate (finalCallback) { | 11 | function 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 | ||
79 | function getMigrationScripts (callback) { | 79 | type GetMigrationScriptsCallback = (err: Error, filesToMigrate?: { version: string, script: string }[]) => void |
80 | function 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 | ||
98 | function executeMigration (actualVersion, entity, callback) { | 99 | function 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 |