mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
rerun interrupted migrations
This commit is contained in:
parent
15de4e3cea
commit
f2808ee764
2 changed files with 25 additions and 13 deletions
|
@ -6,6 +6,7 @@
|
|||
* Notifications is now a nav menu item.
|
||||
* Renamed `comments` to `commentsCount` on `Post` model.
|
||||
* Now tracking list of commenters `_id`s on `Post` model.
|
||||
* Rerun interrupted migrations.
|
||||
|
||||
## v0.9.2.5 “AccountScope”
|
||||
|
||||
|
|
|
@ -13,21 +13,32 @@ Meteor.startup(function () {
|
|||
|
||||
// wrapper function for all migrations
|
||||
var runMigration = function (migrationName) {
|
||||
// migration updatePostStatus: make sure posts have a status
|
||||
if (!Migrations.findOne({name: migrationName})) {
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Starting "+migrationName+" Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
Migrations.insert({name: migrationName, startedAt: new Date(), completed: false});
|
||||
var migration = Migrations.findOne({name: migrationName});
|
||||
|
||||
// execute migration function
|
||||
var itemsAffected = migrationsList[migrationName]() || 0;
|
||||
|
||||
Migrations.update({name: migrationName}, {$set: {finishedAt: new Date(), completed: true, itemsAffected: itemsAffected}});
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Ending "+migrationName+" Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
if (migration){
|
||||
if(typeof migration.finishedAt === 'undefined'){
|
||||
// if migration exists but hasn't finished, remove it and start fresh
|
||||
console.log('!!! Found incomplete migration "'+migrationName+'", removing and running again.')
|
||||
Migrations.remove({name: migrationName});
|
||||
}else{
|
||||
// do nothing
|
||||
// console.log('Migration "'+migrationName+'" already exists, doing nothing.')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Starting "+migrationName+" Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
Migrations.insert({name: migrationName, startedAt: new Date(), completed: false});
|
||||
|
||||
// execute migration function
|
||||
var itemsAffected = migrationsList[migrationName]() || 0;
|
||||
|
||||
Migrations.update({name: migrationName}, {$set: {finishedAt: new Date(), completed: true, itemsAffected: itemsAffected}});
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
console.log("//------------// Ending "+migrationName+" Migration //-----------//");
|
||||
console.log("//----------------------------------------------------------------------//");
|
||||
}
|
||||
|
||||
var migrationsList = {
|
||||
|
|
Loading…
Add table
Reference in a new issue