From eed2ac728ccabd120f23d838123bbedce5392bf0 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Wed, 16 Jul 2014 16:24:22 +0100 Subject: [PATCH] Hacky FORCE_MIGRATION env var refs #2600 One day in the future it would be nice to have a CLI for Ghost In the meantime, lets have an easy way to force migrations to run This is for development, or dead end situations only It will at least do a DB backup ;) --- core/server/data/migration/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/server/data/migration/index.js b/core/server/data/migration/index.js index e42f8e4343..fec844abd9 100644 --- a/core/server/data/migration/index.js +++ b/core/server/data/migration/index.js @@ -62,12 +62,8 @@ init = function () { // 4. The database has not yet been created return versioning.getDatabaseVersion().then(function (databaseVersion) { var defaultVersion = versioning.getDefaultDatabaseVersion(); - if (databaseVersion === defaultVersion) { - // 1. The database exists and is up-to-date - logInfo('Up to date at version ' + databaseVersion); - return when.resolve(); - } - if (databaseVersion < defaultVersion) { + + if (databaseVersion < defaultVersion || process.env.FORCE_MIGRATION) { // 2. The database exists but is out of date // Migrate to latest version logInfo('Database upgrade required from version ' + databaseVersion + ' to ' + defaultVersion); @@ -76,6 +72,13 @@ init = function () { return versioning.setDatabaseVersion(); }); } + + if (databaseVersion === defaultVersion) { + // 1. The database exists and is up-to-date + logInfo('Up to date at version ' + databaseVersion); + return when.resolve(); + } + if (databaseVersion > defaultVersion) { // 3. The database exists but the currentVersion setting does not or cannot be understood // In this case we don't understand the version because it is too high