+ // Search in "Applications" or "application" tables
+ try {
+ const [ rows ] = await sequelizeTypescript.query('SELECT "migrationVersion" FROM "Applications"')
+ if (rows && rows[ 0 ] && rows[ 0 ].migrationVersion) {
+ actualVersion = rows[ 0 ].migrationVersion
+ }
+ } catch {
+ const [ rows ] = await sequelizeTypescript.query('SELECT "migrationVersion" FROM "application"')
+ if (rows && rows[0] && rows[0].migrationVersion) {
+ actualVersion = rows[0].migrationVersion
+ }
+ }
+
+ if (actualVersion === null) {
+ await sequelizeTypescript.query('INSERT INTO "application" ("migrationVersion") VALUES (0)')
+ actualVersion = 0
+ }
+
+ // No need migrations, abort
+ if (actualVersion >= LAST_MIGRATION_VERSION) return
+
+ // If there are a new migration scripts
+ logger.info('Begin migrations.')
+
+ const migrationScripts = await getMigrationScripts()