You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/12/29 09:28:31 UTC
[14/15] ignite git commit: IGNITE-6647 Web Console: Support recreate
index in migrations.
IGNITE-6647 Web Console: Support recreate index in migrations.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a1b1f6c9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a1b1f6c9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a1b1f6c9
Branch: refs/heads/ignite-zk
Commit: a1b1f6c94778dc5277276a46500baa93c3beaad7
Parents: b206085
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Thu Dec 28 17:07:58 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Dec 29 10:23:30 2017 +0700
----------------------------------------------------------------------
modules/web-console/backend/index.js | 6 ++--
.../backend/migrations/recreate-index.js | 30 ++++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1b1f6c9/modules/web-console/backend/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/index.js b/modules/web-console/backend/index.js
index 266fa54..013de47 100644
--- a/modules/web-console/backend/index.js
+++ b/modules/web-console/backend/index.js
@@ -106,11 +106,13 @@ const init = ([settings, apiSrv, agentsHnd, browsersHnd]) => {
* @param dbConnectionUri Mongo connection url.
* @param group Migrations group.
* @param migrationsPath Migrations path.
+ * @param collectionName Name of collection where migrations write info about applied scripts.
*/
-const migrate = (dbConnectionUri, group, migrationsPath) => {
+const migrate = (dbConnectionUri, group, migrationsPath, collectionName) => {
const migrator = new MigrateMongoose({
migrationsPath,
dbConnectionUri,
+ collectionName,
autosync: true
});
@@ -144,7 +146,7 @@ injector.log.debug = () => {};
Promise.all([injector('settings'), injector('mongo')])
.then(([{mongoUrl}]) => {
return migrate(mongoUrl, 'Ignite', path.join(__dirname, 'migrations'))
- .then(() => migrate(mongoUrl, 'Ignite Modules', path.join(igniteModules, 'migrations')));
+ .then(() => migrate(mongoUrl, 'Ignite Modules', path.join(igniteModules, 'migrations'), 'migrationsModules'));
})
.then(() => Promise.all([injector('settings'), injector('api-server'), injector('agents-handler'), injector('browsers-handler')]))
.then(init)
http://git-wip-us.apache.org/repos/asf/ignite/blob/a1b1f6c9/modules/web-console/backend/migrations/recreate-index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/migrations/recreate-index.js b/modules/web-console/backend/migrations/recreate-index.js
new file mode 100644
index 0000000..328ed43
--- /dev/null
+++ b/modules/web-console/backend/migrations/recreate-index.js
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+module.exports = function(done, model, oldIdxName, oldIdx, newIdx) {
+ model.indexExists(oldIdxName)
+ .then((exists) => {
+ if (exists) {
+ return model.dropIndex(oldIdx)
+ .then(() => model.createIndex(newIdx, {unique: true}));
+ }
+ })
+ .then(() => done())
+ .catch(done);
+};