You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2014/09/12 12:29:24 UTC

[10/28] git commit: [#7527] Split the migration into 3 steps

[#7527] Split the migration into 3 steps


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/e76619ab
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e76619ab
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e76619ab

Branch: refs/heads/je/42cc_4905
Commit: e76619abd227889c72b1a168f9732659ce200940
Parents: e3eaaa0
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Fri Aug 22 14:37:38 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 28 20:27:01 2014 +0000

----------------------------------------------------------------------
 ...email-address-_id-to-email--after-upgrade.js |  2 ++
 ...mail-address-_id-to-email--before-upgrade.js |  6 ++++++
 .../030-email-address-_id-to-email--cleanup.js  |  8 ++++++++
 .../030-email-address-_id-to-email.js           | 20 --------------------
 4 files changed, 16 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e76619ab/scripts/migrations/030-email-address-_id-to-email--after-upgrade.js
----------------------------------------------------------------------
diff --git a/scripts/migrations/030-email-address-_id-to-email--after-upgrade.js b/scripts/migrations/030-email-address-_id-to-email--after-upgrade.js
new file mode 100644
index 0000000..7e47a82
--- /dev/null
+++ b/scripts/migrations/030-email-address-_id-to-email--after-upgrade.js
@@ -0,0 +1,2 @@
+db.email_address.renameCollection("email_address_old", {dropTarget: true});
+db.email_address_new.renameCollection("email_address", {dropTarget: true});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/e76619ab/scripts/migrations/030-email-address-_id-to-email--before-upgrade.js
----------------------------------------------------------------------
diff --git a/scripts/migrations/030-email-address-_id-to-email--before-upgrade.js b/scripts/migrations/030-email-address-_id-to-email--before-upgrade.js
new file mode 100644
index 0000000..6681864
--- /dev/null
+++ b/scripts/migrations/030-email-address-_id-to-email--before-upgrade.js
@@ -0,0 +1,6 @@
+db.email_address.find().snapshot().forEach(function (e) {
+    e.email = e._id;
+    e._id = new ObjectId();
+    db.email_address_new.insert(e);
+    db.email_address.update({'_id': e._id}, {'migrated': true});
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/e76619ab/scripts/migrations/030-email-address-_id-to-email--cleanup.js
----------------------------------------------------------------------
diff --git a/scripts/migrations/030-email-address-_id-to-email--cleanup.js b/scripts/migrations/030-email-address-_id-to-email--cleanup.js
new file mode 100644
index 0000000..26b0064
--- /dev/null
+++ b/scripts/migrations/030-email-address-_id-to-email--cleanup.js
@@ -0,0 +1,8 @@
+db.email_address_old.find({'migrated': {'$ne': false}}).snapshot().forEach(function (e) {
+    e.email = e._id;
+    e._id = new ObjectId();
+    db.email_address.insert(e);
+    db.email_address_old.update({'_id': e._id}, {'migrated': true});
+});
+// Drop the collection manually if everything is okay
+// db.email_address_old.drop();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/e76619ab/scripts/migrations/030-email-address-_id-to-email.js
----------------------------------------------------------------------
diff --git a/scripts/migrations/030-email-address-_id-to-email.js b/scripts/migrations/030-email-address-_id-to-email.js
deleted file mode 100644
index f831623..0000000
--- a/scripts/migrations/030-email-address-_id-to-email.js
+++ /dev/null
@@ -1,20 +0,0 @@
-//1) Copy to the new collection with data updates
-db.email_address.find().snapshot().forEach(function(e){
-    e.email = e._id;
-    e._id = new ObjectId();
-    db.email_address_new.insert(e);
-    db.email_address.update({'_id': e._id}, {'migrated': true})
-});
-//2) Updated code on production(git pull)
-//3) Rename collections
-db.email_address.renameCollection("email_address_old", {dropTarget: true})
-db.email_address_new.renameCollection("email_address", {dropTarget: true})
-//4) Post Migration - copy/update all the object which were created between 1)&2)
-db.email_address_old.find({'migrated': {'$not': false}}).snapshot().forEach(function(e){
-    e.email = e._id;
-    e._id = new ObjectId();
-    db.email_address.insert(e);
-    db.email_address_old.update({'_id': e._id}, {'migrated': true})
-});
-
-db.email_address_old.drop()