diff --git a/server/startup/migrations/v041.js b/server/startup/migrations/v041.js
index da2b432743e5..83085e1e5c44 100644
--- a/server/startup/migrations/v041.js
+++ b/server/startup/migrations/v041.js
@@ -1,10 +1,13 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 41,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Users) {
- RocketChat.models.Users.update({ bot: true }, { $set: { type: 'bot' } }, { multi: true });
- RocketChat.models.Users.update({ 'profile.guest': true }, { $set: { type: 'visitor' } }, { multi: true });
- RocketChat.models.Users.update({ type: { $exists: false } }, { $set: { type: 'user' } }, { multi: true });
+ if (Users) {
+ Users.update({ bot: true }, { $set: { type: 'bot' } }, { multi: true });
+ Users.update({ 'profile.guest': true }, { $set: { type: 'visitor' } }, { multi: true });
+ Users.update({ type: { $exists: false } }, { $set: { type: 'user' } }, { multi: true });
}
},
});
diff --git a/server/startup/migrations/v042.js b/server/startup/migrations/v042.js
index e97cb83bf8c9..275d99f1ca44 100644
--- a/server/startup/migrations/v042.js
+++ b/server/startup/migrations/v042.js
@@ -1,10 +1,13 @@
import { Mongo } from 'meteor/mongo';
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { settings } from 'meteor/rocketchat:settings';
+import { RocketChatAssets } from 'meteor/rocketchat:assets';
-RocketChat.Migrations.add({
+Migrations.add({
version: 42,
up() {
- const files = RocketChat.__migration_assets_files = new Mongo.Collection('assets.files');
- const chunks = RocketChat.__migration_assets_chunks = new Mongo.Collection('assets.chunks');
+ const files = new Mongo.Collection('assets.files');
+ const chunks = new Mongo.Collection('assets.chunks');
const list = {
'favicon.ico': 'favicon_ico',
'favicon.svg': 'favicon',
@@ -28,11 +31,11 @@ RocketChat.Migrations.add({
});
if (oldFile) {
- const extension = RocketChat.Assets.mime.extension(oldFile.contentType);
- RocketChat.settings.removeById(`Assets_${ from }`);
- RocketChat.settings.updateById(`Assets_${ to }`, {
+ const extension = RocketChatAssets.mime.extension(oldFile.contentType);
+ settings.removeById(`Assets_${ from }`);
+ settings.updateById(`Assets_${ to }`, {
url: `/assets/${ to }.${ extension }`,
- defaultUrl: RocketChat.Assets.assets[to].defaultUrl,
+ defaultUrl: RocketChatAssets.assets[to].defaultUrl,
});
oldFile._id = to;
diff --git a/server/startup/migrations/v043.js b/server/startup/migrations/v043.js
index 87867c358f49..209d0f60e2dd 100644
--- a/server/startup/migrations/v043.js
+++ b/server/startup/migrations/v043.js
@@ -1,8 +1,11 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Permissions } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 43,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Permissions) {
- RocketChat.models.Permissions.update({ _id: 'pin-message' }, { $addToSet: { roles: 'admin' } });
+ if (Permissions) {
+ Permissions.update({ _id: 'pin-message' }, { $addToSet: { roles: 'admin' } });
}
},
});
diff --git a/server/startup/migrations/v044.js b/server/startup/migrations/v044.js
index 490643740956..fb6f0a6f4a0f 100644
--- a/server/startup/migrations/v044.js
+++ b/server/startup/migrations/v044.js
@@ -1,19 +1,22 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users, Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 44,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Users) {
- RocketChat.models.Users.find({ $or: [{ 'settings.preferences.disableNewRoomNotification': { $exists: 1 } }, { 'settings.preferences.disableNewMessageNotification': { $exists: 1 } }] }).forEach(function(user) {
+ if (Users) {
+ Users.find({ $or: [{ 'settings.preferences.disableNewRoomNotification': { $exists: 1 } }, { 'settings.preferences.disableNewMessageNotification': { $exists: 1 } }] }).forEach(function(user) {
const newRoomNotification = !(user && user.settings && user.settings.preferences && user.settings.preferences.disableNewRoomNotification);
const newMessageNotification = !(user && user.settings && user.settings.preferences && user.settings.preferences.disableNewMessageNotification);
- RocketChat.models.Users.update({ _id: user._id }, { $unset: { 'settings.preferences.disableNewRoomNotification': 1, 'settings.preferences.disableNewMessageNotification': 1 }, $set: { 'settings.preferences.newRoomNotification': newRoomNotification, 'settings.preferences.newMessageNotification': newMessageNotification } });
+ Users.update({ _id: user._id }, { $unset: { 'settings.preferences.disableNewRoomNotification': 1, 'settings.preferences.disableNewMessageNotification': 1 }, $set: { 'settings.preferences.newRoomNotification': newRoomNotification, 'settings.preferences.newMessageNotification': newMessageNotification } });
});
}
- if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
- const optOut = RocketChat.models.Settings.findOne({ _id: 'Statistics_opt_out' });
+ if (Settings) {
+ const optOut = Settings.findOne({ _id: 'Statistics_opt_out' });
if (optOut) {
- RocketChat.models.Settings.remove({ _id: 'Statistics_opt_out' });
- RocketChat.models.Settings.upsert({ _id: 'Statistics_reporting' }, {
+ Settings.remove({ _id: 'Statistics_opt_out' });
+ Settings.upsert({ _id: 'Statistics_reporting' }, {
$set: {
value: !optOut.value,
i18nDescription: 'Statistics_reporting_Description',
@@ -24,11 +27,11 @@ RocketChat.Migrations.add({
}
}
- if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
- const favoriteRooms = RocketChat.models.Settings.findOne({ _id: 'Disable_Favorite_Rooms' });
+ if (Settings) {
+ const favoriteRooms = Settings.findOne({ _id: 'Disable_Favorite_Rooms' });
if (favoriteRooms) {
- RocketChat.models.Settings.remove({ _id: 'Disable_Favorite_Rooms' });
- RocketChat.models.Settings.upsert({ _id: 'Favorite_Rooms' }, {
+ Settings.remove({ _id: 'Disable_Favorite_Rooms' });
+ Settings.upsert({ _id: 'Favorite_Rooms' }, {
$set: {
value: !favoriteRooms.value,
i18nDescription: 'Favorite_Rooms_Description',
diff --git a/server/startup/migrations/v045.js b/server/startup/migrations/v045.js
index 2be7c4ae3fe9..c43b9e837ef3 100644
--- a/server/startup/migrations/v045.js
+++ b/server/startup/migrations/v045.js
@@ -1,14 +1,18 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users } from 'meteor/rocketchat:models';
+import { settings } from 'meteor/rocketchat:settings';
+
+Migrations.add({
version: 45,
up() {
// finds the latest created visitor
- const lastVisitor = RocketChat.models.Users.find({ type: 'visitor' }, { fields: { username: 1 }, sort: { createdAt: -1 }, limit: 1 }).fetch();
+ const lastVisitor = Users.find({ type: 'visitor' }, { fields: { username: 1 }, sort: { createdAt: -1 }, limit: 1 }).fetch();
if (lastVisitor && lastVisitor.length > 0) {
const lastNumber = lastVisitor[0].username.replace(/^guest\-/, '');
- RocketChat.settings.add('Livechat_guest_count', (parseInt(lastNumber) + 1), { type: 'int', group: 'Livechat' });
+ settings.add('Livechat_guest_count', (parseInt(lastNumber) + 1), { type: 'int', group: 'Livechat' });
}
},
});
diff --git a/server/startup/migrations/v046.js b/server/startup/migrations/v046.js
index 3d171be15ae0..ea167add41c1 100644
--- a/server/startup/migrations/v046.js
+++ b/server/startup/migrations/v046.js
@@ -1,8 +1,11 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 46,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Users) {
- RocketChat.models.Users.update({ type: { $exists: false } }, { $set: { type: 'user' } }, { multi: true });
+ if (Users) {
+ Users.update({ type: { $exists: false } }, { $set: { type: 'user' } }, { multi: true });
}
},
});
diff --git a/server/startup/migrations/v047.js b/server/startup/migrations/v047.js
index 2ecbe80c7943..082068c4503b 100644
--- a/server/startup/migrations/v047.js
+++ b/server/startup/migrations/v047.js
@@ -1,23 +1,26 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 47,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
- const autolinkerUrls = RocketChat.models.Settings.findOne({ _id: 'AutoLinker_Urls' });
+ if (Settings) {
+ const autolinkerUrls = Settings.findOne({ _id: 'AutoLinker_Urls' });
if (autolinkerUrls) {
- RocketChat.models.Settings.remove({ _id: 'AutoLinker_Urls' });
- RocketChat.models.Settings.upsert({ _id: 'AutoLinker_Urls_Scheme' }, {
+ Settings.remove({ _id: 'AutoLinker_Urls' });
+ Settings.upsert({ _id: 'AutoLinker_Urls_Scheme' }, {
$set: {
value: !!autolinkerUrls.value,
i18nLabel: 'AutoLinker_Urls_Scheme',
},
});
- RocketChat.models.Settings.upsert({ _id: 'AutoLinker_Urls_www' }, {
+ Settings.upsert({ _id: 'AutoLinker_Urls_www' }, {
$set: {
value: !!autolinkerUrls.value,
i18nLabel: 'AutoLinker_Urls_www',
},
});
- RocketChat.models.Settings.upsert({ _id: 'AutoLinker_Urls_TLD' }, {
+ Settings.upsert({ _id: 'AutoLinker_Urls_TLD' }, {
$set: {
value: !!autolinkerUrls.value,
i18nLabel: 'AutoLinker_Urls_TLD',
diff --git a/server/startup/migrations/v048.js b/server/startup/migrations/v048.js
index 731f38ef0886..cce3861e5826 100644
--- a/server/startup/migrations/v048.js
+++ b/server/startup/migrations/v048.js
@@ -1,16 +1,19 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 48,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
+ if (Settings) {
- const RocketBot_Enabled = RocketChat.models.Settings.findOne({
+ const RocketBot_Enabled = Settings.findOne({
_id: 'RocketBot_Enabled',
});
if (RocketBot_Enabled) {
- RocketChat.models.Settings.remove({
+ Settings.remove({
_id: 'RocketBot_Enabled',
});
- RocketChat.models.Settings.upsert({
+ Settings.upsert({
_id: 'InternalHubot_Enabled',
}, {
$set: {
@@ -19,14 +22,14 @@ RocketChat.Migrations.add({
});
}
- const RocketBot_Name = RocketChat.models.Settings.findOne({
+ const RocketBot_Name = Settings.findOne({
_id: 'RocketBot_Name',
});
if (RocketBot_Name) {
- RocketChat.models.Settings.remove({
+ Settings.remove({
_id: 'RocketBot_Name',
});
- RocketChat.models.Settings.upsert({
+ Settings.upsert({
_id: 'InternalHubot_Username',
}, {
$set: {
diff --git a/server/startup/migrations/v049.js b/server/startup/migrations/v049.js
index 635ba13afb42..6bdb839bfd1b 100644
--- a/server/startup/migrations/v049.js
+++ b/server/startup/migrations/v049.js
@@ -1,16 +1,19 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Rooms, Subscriptions, Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 49,
up() {
let count = 1;
- RocketChat.models.Rooms.find({ t: 'l' }, { sort: { ts: 1 }, fields: { _id: 1 } }).forEach(function(room) {
- RocketChat.models.Rooms.update({ _id: room._id }, { $set: { code: count } });
- RocketChat.models.Subscriptions.update({ rid: room._id }, { $set: { code: count } }, { multi: true });
+ Rooms.find({ t: 'l' }, { sort: { ts: 1 }, fields: { _id: 1 } }).forEach(function(room) {
+ Rooms.update({ _id: room._id }, { $set: { code: count } });
+ Subscriptions.update({ rid: room._id }, { $set: { code: count } }, { multi: true });
count++;
});
- RocketChat.models.Settings.upsert({ _id: 'Livechat_Room_Count' }, {
+ Settings.upsert({ _id: 'Livechat_Room_Count' }, {
$set: {
value: count,
type: 'int',
diff --git a/server/startup/migrations/v050.js b/server/startup/migrations/v050.js
index 769ce1c1cddd..92bb06aa68fa 100644
--- a/server/startup/migrations/v050.js
+++ b/server/startup/migrations/v050.js
@@ -1,7 +1,10 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Subscriptions } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 50,
up() {
- RocketChat.models.Subscriptions.tryDropIndex('u._id_1_name_1_t_1');
- RocketChat.models.Subscriptions.tryEnsureIndex({ 'u._id': 1, name: 1, t: 1 });
+ Subscriptions.tryDropIndex('u._id_1_name_1_t_1');
+ Subscriptions.tryEnsureIndex({ 'u._id': 1, name: 1, t: 1 });
},
});
diff --git a/server/startup/migrations/v051.js b/server/startup/migrations/v051.js
index 5f1c4da7719b..3c43c1d2ae4c 100644
--- a/server/startup/migrations/v051.js
+++ b/server/startup/migrations/v051.js
@@ -1,16 +1,19 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users, Rooms, Subscriptions } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 51,
up() {
- RocketChat.models.Rooms.find({ t: 'l', 'v.token': { $exists: true }, label: { $exists: false } }).forEach(function(room) {
- const user = RocketChat.models.Users.findOne({ 'profile.token': room.v.token });
+ Rooms.find({ t: 'l', 'v.token': { $exists: true }, label: { $exists: false } }).forEach(function(room) {
+ const user = Users.findOne({ 'profile.token': room.v.token });
if (user) {
- RocketChat.models.Rooms.update({ _id: room._id }, {
+ Rooms.update({ _id: room._id }, {
$set: {
label: user.name || user.username,
'v._id': user._id,
},
});
- RocketChat.models.Subscriptions.update({ rid: room._id }, {
+ Subscriptions.update({ rid: room._id }, {
$set: {
name: user.name || user.username,
},
diff --git a/server/startup/migrations/v052.js b/server/startup/migrations/v052.js
index 477ed1908552..e1a30bd5941a 100644
--- a/server/startup/migrations/v052.js
+++ b/server/startup/migrations/v052.js
@@ -1,6 +1,9 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 52,
up() {
- RocketChat.models.Users.update({ _id: 'rocket.cat' }, { $addToSet: { roles: 'bot' } });
+ Users.update({ _id: 'rocket.cat' }, { $addToSet: { roles: 'bot' } });
},
});
diff --git a/server/startup/migrations/v053.js b/server/startup/migrations/v053.js
index 78c6b10d606e..39534a3580b3 100644
--- a/server/startup/migrations/v053.js
+++ b/server/startup/migrations/v053.js
@@ -1,13 +1,16 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 53,
up() {
- RocketChat.models.Settings.update({ _id: 'Email_Header', value: '' }, {
+ Settings.update({ _id: 'Email_Header', value: '' }, {
$set: {
value: '
[Site_Name] | ',
},
});
- RocketChat.models.Settings.update({ _id: 'Email_Footer', value: '' }, {
+ Settings.update({ _id: 'Email_Footer', value: '' }, {
$set: {
value: ' |
| Powered by Rocket.Chat |
|
',
},
diff --git a/server/startup/migrations/v054.js b/server/startup/migrations/v054.js
index 29a911f62b55..a44b9db19642 100644
--- a/server/startup/migrations/v054.js
+++ b/server/startup/migrations/v054.js
@@ -1,10 +1,13 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 54,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Users) {
+ if (Users) {
// Set default message viewMode to 'normal' or 'cozy' depending on the users' current settings and remove the field 'compactView'
- RocketChat.models.Users.update({ 'settings.preferences.compactView': true }, { $set: { 'settings.preferences.viewMode': 1 }, $unset: { 'settings.preferences.compactView': 1 } }, { multi: true });
- RocketChat.models.Users.update({ 'settings.preferences.viewMode': { $ne: 1 } }, { $set: { 'settings.preferences.viewMode': 0 } }, { multi: true });
+ Users.update({ 'settings.preferences.compactView': true }, { $set: { 'settings.preferences.viewMode': 1 }, $unset: { 'settings.preferences.compactView': 1 } }, { multi: true });
+ Users.update({ 'settings.preferences.viewMode': { $ne: 1 } }, { $set: { 'settings.preferences.viewMode': 0 } }, { multi: true });
}
},
});
diff --git a/server/startup/migrations/v055.js b/server/startup/migrations/v055.js
index 1e8cd34ed718..6e840d767118 100644
--- a/server/startup/migrations/v055.js
+++ b/server/startup/migrations/v055.js
@@ -1,12 +1,14 @@
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Rooms, Messages } from 'meteor/rocketchat:models';
import s from 'underscore.string';
-RocketChat.Migrations.add({
+Migrations.add({
version: 55,
up() {
- RocketChat.models.Rooms.find({ topic: { $exists: 1, $ne: '' } }, { topic: 1 }).forEach(function(room) {
+ Rooms.find({ topic: { $exists: 1, $ne: '' } }, { topic: 1 }).forEach(function(room) {
const topic = s.escapeHTML(room.topic);
- RocketChat.models.Rooms.update({ _id: room._id }, { $set: { topic } });
- RocketChat.models.Messages.update({ t: 'room_changed_topic', rid: room._id }, { $set: { msg: topic } });
+ Rooms.update({ _id: room._id }, { $set: { topic } });
+ Messages.update({ t: 'room_changed_topic', rid: room._id }, { $set: { msg: topic } });
});
},
});
diff --git a/server/startup/migrations/v056.js b/server/startup/migrations/v056.js
index 174498b503af..507f7ddf0f0e 100644
--- a/server/startup/migrations/v056.js
+++ b/server/startup/migrations/v056.js
@@ -1,11 +1,14 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Messages } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 56,
up() {
- RocketChat.models.Messages.find({ _id: /\./ }).forEach(function(message) {
+ Messages.find({ _id: /\./ }).forEach(function(message) {
const oldId = message._id;
message._id = message._id.replace(/(.*)\.S?(.*)/, 'slack-$1-$2');
- RocketChat.models.Messages.insert(message);
- RocketChat.models.Messages.remove({ _id: oldId });
+ Messages.insert(message);
+ Messages.remove({ _id: oldId });
});
},
});
diff --git a/server/startup/migrations/v057.js b/server/startup/migrations/v057.js
index 0f80972aed78..c2a070becbf7 100644
--- a/server/startup/migrations/v057.js
+++ b/server/startup/migrations/v057.js
@@ -1,27 +1,30 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Messages } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 57,
up() {
- RocketChat.models.Messages.find({ _id: /slack-([a-zA-Z0-9]+)S([0-9]+-[0-9]+)/ }).forEach(function(message) {
+ Messages.find({ _id: /slack-([a-zA-Z0-9]+)S([0-9]+-[0-9]+)/ }).forEach(function(message) {
const oldId = message._id;
message._id = message._id.replace(/slack-([a-zA-Z0-9]+)S([0-9]+-[0-9]+)/, 'slack-$1-$2');
- RocketChat.models.Messages.insert(message);
- RocketChat.models.Messages.remove({ _id: oldId });
+ Messages.insert(message);
+ Messages.remove({ _id: oldId });
});
- RocketChat.models.Messages.find({ _id: /slack-slack/ }).forEach(function(message) {
+ Messages.find({ _id: /slack-slack/ }).forEach(function(message) {
const oldId = message._id;
message._id = message._id.replace('slack-slack', 'slack');
- RocketChat.models.Messages.insert(message);
- RocketChat.models.Messages.remove({ _id: oldId });
+ Messages.insert(message);
+ Messages.remove({ _id: oldId });
});
- RocketChat.models.Messages.find({ _id: /\./ }).forEach(function(message) {
+ Messages.find({ _id: /\./ }).forEach(function(message) {
const oldId = message._id;
message._id = message._id.replace(/(.*)\.?S(.*)/, 'slack-$1-$2');
message._id = message._id.replace(/\./g, '-');
- RocketChat.models.Messages.remove({ _id: message._id });
- RocketChat.models.Messages.insert(message);
- RocketChat.models.Messages.remove({ _id: oldId });
+ Messages.remove({ _id: message._id });
+ Messages.insert(message);
+ Messages.remove({ _id: oldId });
});
},
});
diff --git a/server/startup/migrations/v058.js b/server/startup/migrations/v058.js
index bcee11484db0..ec7924da5a0f 100644
--- a/server/startup/migrations/v058.js
+++ b/server/startup/migrations/v058.js
@@ -1,7 +1,10 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 58,
up() {
- RocketChat.models.Settings.update({ _id: 'Push_gateway', value: 'https://rocket.chat' }, {
+ Settings.update({ _id: 'Push_gateway', value: 'https://rocket.chat' }, {
$set: {
value: 'https://gateway.rocket.chat',
packageValue: 'https://gateway.rocket.chat',
diff --git a/server/startup/migrations/v059.js b/server/startup/migrations/v059.js
index 9e8a0bdcd458..9340604f2dc8 100644
--- a/server/startup/migrations/v059.js
+++ b/server/startup/migrations/v059.js
@@ -1,12 +1,13 @@
-import { Statistics } from 'meteor/rocketchat:models';
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users, Settings, Statistics } from 'meteor/rocketchat:models';
-RocketChat.Migrations.add({
+Migrations.add({
version: 59,
up() {
- const users = RocketChat.models.Users.find({}, { sort: { createdAt: 1 }, limit: 1 }).fetch();
+ const users = Users.find({}, { sort: { createdAt: 1 }, limit: 1 }).fetch();
if (users && users.length > 0) {
const { createdAt } = users[0];
- RocketChat.models.Settings.update({ createdAt: { $exists: 0 } }, { $set: { createdAt } }, { multi: true });
+ Settings.update({ createdAt: { $exists: 0 } }, { $set: { createdAt } }, { multi: true });
Statistics.update({ installedAt: { $exists: 0 } }, { $set: { installedAt: createdAt } }, { multi: true });
}
},
diff --git a/server/startup/migrations/v060.js b/server/startup/migrations/v060.js
index d5d3460a98fc..30c3b1ac77d2 100644
--- a/server/startup/migrations/v060.js
+++ b/server/startup/migrations/v060.js
@@ -1,17 +1,19 @@
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users, Subscriptions } from 'meteor/rocketchat:models';
import _ from 'underscore';
-RocketChat.Migrations.add({
+Migrations.add({
version: 60,
up() {
- let subscriptions = RocketChat.models.Subscriptions.find({ $or: [{ name: { $exists: 0 } }, { name: { $not: { $type: 2 } } }] }).fetch();
+ let subscriptions = Subscriptions.find({ $or: [{ name: { $exists: 0 } }, { name: { $not: { $type: 2 } } }] }).fetch();
if (subscriptions && subscriptions.length > 0) {
- RocketChat.models.Subscriptions.remove({ _id: { $in: _.pluck(subscriptions, '_id') } });
+ Subscriptions.remove({ _id: { $in: _.pluck(subscriptions, '_id') } });
}
- subscriptions = RocketChat.models.Subscriptions.find().forEach(function(subscription) {
- const user = RocketChat.models.Users.findOne({ _id: subscription && subscription.u && subscription.u._id });
+ subscriptions = Subscriptions.find().forEach(function(subscription) {
+ const user = Users.findOne({ _id: subscription && subscription.u && subscription.u._id });
if (!user) {
- RocketChat.models.Subscriptions.remove({ _id: subscription._id });
+ Subscriptions.remove({ _id: subscription._id });
}
});
},
diff --git a/server/startup/migrations/v061.js b/server/startup/migrations/v061.js
index 5f7cae3b2da1..b39f2e20b14d 100644
--- a/server/startup/migrations/v061.js
+++ b/server/startup/migrations/v061.js
@@ -1,8 +1,11 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users, Subscriptions } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 61,
up() {
- RocketChat.models.Users.find({ active: false }).forEach(function(user) {
- RocketChat.models.Subscriptions.setArchivedByUsername(user.username, true);
+ Users.find({ active: false }).forEach(function(user) {
+ Subscriptions.setArchivedByUsername(user.username, true);
});
},
});
diff --git a/server/startup/migrations/v062.js b/server/startup/migrations/v062.js
index 32699b65b552..83a35ad40b8c 100644
--- a/server/startup/migrations/v062.js
+++ b/server/startup/migrations/v062.js
@@ -1,6 +1,9 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 62,
up() {
- RocketChat.models.Settings.remove({ _id: 'Atlassian Crowd', type: 'group' });
+ Settings.remove({ _id: 'Atlassian Crowd', type: 'group' });
},
});
diff --git a/server/startup/migrations/v063.js b/server/startup/migrations/v063.js
index c2a3efca6a15..66e56986c70b 100644
--- a/server/startup/migrations/v063.js
+++ b/server/startup/migrations/v063.js
@@ -1,11 +1,14 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 63,
up() {
- const forward = RocketChat.models.Settings.findOne({ _id:'Livechat_forward_open_chats' });
- const timeout = RocketChat.models.Settings.findOne({ _id:'Livechat_forward_open_chats_timeout' });
+ const forward = Settings.findOne({ _id:'Livechat_forward_open_chats' });
+ const timeout = Settings.findOne({ _id:'Livechat_forward_open_chats_timeout' });
if (forward && forward.value) {
- RocketChat.models.Settings.upsert({ _id: 'Livechat_agent_leave_action' }, {
+ Settings.upsert({ _id: 'Livechat_agent_leave_action' }, {
$set: {
value: 'forward',
type: 'string',
@@ -15,7 +18,7 @@ RocketChat.Migrations.add({
}
if (timeout && timeout.value !== 60) {
- RocketChat.models.Settings.upsert({ _id: 'Livechat_agent_leave_action_timeout' }, {
+ Settings.upsert({ _id: 'Livechat_agent_leave_action_timeout' }, {
$set: {
value: timeout.value,
type: 'int',
@@ -24,7 +27,7 @@ RocketChat.Migrations.add({
});
}
- RocketChat.models.Settings.remove({ _id: 'Livechat_forward_open_chats' });
- RocketChat.models.Settings.remove({ _id: 'Livechat_forward_open_chats_timeout' });
+ Settings.remove({ _id: 'Livechat_forward_open_chats' });
+ Settings.remove({ _id: 'Livechat_forward_open_chats_timeout' });
},
});
diff --git a/server/startup/migrations/v064.js b/server/startup/migrations/v064.js
index 84445248e82e..84ece66ae7fd 100644
--- a/server/startup/migrations/v064.js
+++ b/server/startup/migrations/v064.js
@@ -1,11 +1,13 @@
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Messages } from 'meteor/rocketchat:models';
import s from 'underscore.string';
-RocketChat.Migrations.add({
+Migrations.add({
version: 64,
up() {
- RocketChat.models.Messages.find({ t: 'room_changed_topic', msg: / }, { msg: 1 }).forEach(function(message) {
+ Messages.find({ t: 'room_changed_topic', msg: / }, { msg: 1 }).forEach(function(message) {
const msg = s.escapeHTML(message.msg);
- RocketChat.models.Messages.update({ _id: message._id }, { $set: { msg } });
+ Messages.update({ _id: message._id }, { $set: { msg } });
});
},
});
diff --git a/server/startup/migrations/v065.js b/server/startup/migrations/v065.js
index 7912b2e15a8a..f2dc833d4b67 100644
--- a/server/startup/migrations/v065.js
+++ b/server/startup/migrations/v065.js
@@ -1,56 +1,59 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 65,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
+ if (Settings) {
// New color settings - start with old settings as defaults
- const replace1 = RocketChat.models.Settings.findOne({ _id: 'theme-color-quaternary-font-color' });
- const replace2 = RocketChat.models.Settings.findOne({ _id: 'theme-color-input-font-color' });
- const replace3 = RocketChat.models.Settings.findOne({ _id: 'theme-color-status-online' });
- const replace4 = RocketChat.models.Settings.findOne({ _id: 'theme-color-status-away' });
- const replace5 = RocketChat.models.Settings.findOne({ _id: 'theme-color-status-busy' });
- const replace6 = RocketChat.models.Settings.findOne({ _id: 'theme-color-info-active-font-color' });
+ const replace1 = Settings.findOne({ _id: 'theme-color-quaternary-font-color' });
+ const replace2 = Settings.findOne({ _id: 'theme-color-input-font-color' });
+ const replace3 = Settings.findOne({ _id: 'theme-color-status-online' });
+ const replace4 = Settings.findOne({ _id: 'theme-color-status-away' });
+ const replace5 = Settings.findOne({ _id: 'theme-color-status-busy' });
+ const replace6 = Settings.findOne({ _id: 'theme-color-info-active-font-color' });
if (replace1) {
- RocketChat.models.Settings.upsert({ _id: 'theme-color-secondary-action-color' }, { $set: { value: replace1.value } });
+ Settings.upsert({ _id: 'theme-color-secondary-action-color' }, { $set: { value: replace1.value } });
}
if (replace2) {
- RocketChat.models.Settings.upsert({ _id: 'theme-color-component-color' }, { $set: { value: replace2.value } });
+ Settings.upsert({ _id: 'theme-color-component-color' }, { $set: { value: replace2.value } });
}
if (replace3) {
- RocketChat.models.Settings.upsert({ _id: 'theme-color-success-color' }, { $set: { value: replace3.value } });
+ Settings.upsert({ _id: 'theme-color-success-color' }, { $set: { value: replace3.value } });
}
if (replace4) {
- RocketChat.models.Settings.upsert({ _id: 'theme-color-pending-color' }, { $set: { value: replace4.value } });
+ Settings.upsert({ _id: 'theme-color-pending-color' }, { $set: { value: replace4.value } });
}
if (replace5) {
- RocketChat.models.Settings.upsert({ _id: 'theme-color-error-color' }, { $set: { value: replace5.value } });
+ Settings.upsert({ _id: 'theme-color-error-color' }, { $set: { value: replace5.value } });
}
if (replace6) {
- RocketChat.models.Settings.upsert({ _id: 'theme-color-selection-color' }, { $set: { value: replace6.value } });
+ Settings.upsert({ _id: 'theme-color-selection-color' }, { $set: { value: replace6.value } });
}
// Renamed color settings
- const oldColor = RocketChat.models.Settings.findOne({ _id: 'theme-color-action-buttons-color' });
+ const oldColor = Settings.findOne({ _id: 'theme-color-action-buttons-color' });
if (oldColor) {
- RocketChat.models.Settings.remove({ _id: 'theme-color-action-buttons-color' });
- RocketChat.models.Settings.upsert({ _id: 'theme-color-primary-action-color' }, { $set: { value: oldColor.value } });
+ Settings.remove({ _id: 'theme-color-action-buttons-color' });
+ Settings.upsert({ _id: 'theme-color-primary-action-color' }, { $set: { value: oldColor.value } });
}
// Removed color settings
- RocketChat.models.Settings.remove({ _id: 'theme-color-quaternary-font-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-active-channel-background-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-active-channel-font-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-blockquote-background' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-clean-buttons-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-code-background' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-code-border' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-code-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-info-active-font-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-input-font-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-message-hover-background-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-smallprint-font-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-smallprint-hover-color' });
- RocketChat.models.Settings.remove({ _id: 'theme-color-unread-notification-color' });
+ Settings.remove({ _id: 'theme-color-quaternary-font-color' });
+ Settings.remove({ _id: 'theme-color-active-channel-background-color' });
+ Settings.remove({ _id: 'theme-color-active-channel-font-color' });
+ Settings.remove({ _id: 'theme-color-blockquote-background' });
+ Settings.remove({ _id: 'theme-color-clean-buttons-color' });
+ Settings.remove({ _id: 'theme-color-code-background' });
+ Settings.remove({ _id: 'theme-color-code-border' });
+ Settings.remove({ _id: 'theme-color-code-color' });
+ Settings.remove({ _id: 'theme-color-info-active-font-color' });
+ Settings.remove({ _id: 'theme-color-input-font-color' });
+ Settings.remove({ _id: 'theme-color-message-hover-background-color' });
+ Settings.remove({ _id: 'theme-color-smallprint-font-color' });
+ Settings.remove({ _id: 'theme-color-smallprint-hover-color' });
+ Settings.remove({ _id: 'theme-color-unread-notification-color' });
}
},
});
diff --git a/server/startup/migrations/v066.js b/server/startup/migrations/v066.js
index 713edb407939..c3beff7b1623 100644
--- a/server/startup/migrations/v066.js
+++ b/server/startup/migrations/v066.js
@@ -1,12 +1,15 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 66,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
+ if (Settings) {
// New color settings - start with old settings as defaults
- const replace1 = RocketChat.models.Settings.findOne({ _id: 'theme-color-tertiary-background-color' });
+ const replace1 = Settings.findOne({ _id: 'theme-color-tertiary-background-color' });
if (replace1) {
- RocketChat.models.Settings.upsert({ _id: 'theme-color-component-color' }, { $set: { value: replace1.value } });
+ Settings.upsert({ _id: 'theme-color-component-color' }, { $set: { value: replace1.value } });
}
}
},
diff --git a/server/startup/migrations/v067.js b/server/startup/migrations/v067.js
index a58a7a35ddfd..e33b5295162e 100644
--- a/server/startup/migrations/v067.js
+++ b/server/startup/migrations/v067.js
@@ -1,6 +1,7 @@
+import { Migrations } from 'meteor/rocketchat:migrations';
import { LivechatDepartment } from 'meteor/rocketchat:models';
-RocketChat.Migrations.add({
+Migrations.add({
version: 67,
up() {
if (LivechatDepartment) {
diff --git a/server/startup/migrations/v068.js b/server/startup/migrations/v068.js
index 822ff974868a..4b6e94857c0c 100644
--- a/server/startup/migrations/v068.js
+++ b/server/startup/migrations/v068.js
@@ -1,17 +1,20 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 68,
up() {
- const GoogleSiteVerification_id = RocketChat.models.Settings.findOne({ _id: 'GoogleSiteVerification_id' });
+ const GoogleSiteVerification_id = Settings.findOne({ _id: 'GoogleSiteVerification_id' });
if (GoogleSiteVerification_id && GoogleSiteVerification_id.value) {
- RocketChat.models.Settings.update({ _id: 'Meta_google-site-verification' }, {
+ Settings.update({ _id: 'Meta_google-site-verification' }, {
$set: {
value: GoogleSiteVerification_id.value,
},
});
}
- RocketChat.models.Settings.remove({ _id: 'GoogleSiteVerification_id' });
+ Settings.remove({ _id: 'GoogleSiteVerification_id' });
},
});
diff --git a/server/startup/migrations/v069.js b/server/startup/migrations/v069.js
index 5904763bf0d6..46a9e1139311 100644
--- a/server/startup/migrations/v069.js
+++ b/server/startup/migrations/v069.js
@@ -1,7 +1,10 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 69,
up() {
- RocketChat.models.Settings.update({
+ Settings.update({
_id: 'theme-color-custom-scrollbar-color',
value: 'rgba(255, 255, 255, 0.05)',
}, {
@@ -10,7 +13,7 @@ RocketChat.Migrations.add({
value: '@transparent-darker',
},
});
- RocketChat.models.Settings.update({
+ Settings.update({
_id: 'theme-color-info-font-color',
value: '#aaaaaa',
}, {
@@ -19,7 +22,7 @@ RocketChat.Migrations.add({
value: '@secondary-font-color',
},
});
- RocketChat.models.Settings.update({
+ Settings.update({
_id: 'theme-color-link-font-color',
value: '#008ce3',
}, {
@@ -28,7 +31,7 @@ RocketChat.Migrations.add({
value: '@primary-action-color',
},
});
- RocketChat.models.Settings.update({
+ Settings.update({
_id: 'theme-color-status-away',
value: '#fcb316',
}, {
@@ -37,7 +40,7 @@ RocketChat.Migrations.add({
value: '@pending-color',
},
});
- RocketChat.models.Settings.update({
+ Settings.update({
_id: 'theme-color-status-busy',
value: '#d30230',
}, {
@@ -46,7 +49,7 @@ RocketChat.Migrations.add({
value: '@error-color',
},
});
- RocketChat.models.Settings.update({
+ Settings.update({
_id: 'theme-color-status-offline',
value: 'rgba(150, 150, 150, 0.50)',
}, {
@@ -55,7 +58,7 @@ RocketChat.Migrations.add({
value: '@transparent-darker',
},
});
- RocketChat.models.Settings.update({
+ Settings.update({
_id: 'theme-color-status-online',
value: '#35ac19',
}, {
@@ -64,7 +67,7 @@ RocketChat.Migrations.add({
value: '@success-color',
},
});
- RocketChat.models.Settings.update({
+ Settings.update({
_id: 'theme-color-tertiary-background-color',
value: '#eaeaea',
}, {
@@ -73,7 +76,7 @@ RocketChat.Migrations.add({
value: '@component-color',
},
});
- return RocketChat.models.Settings.update({
+ return Settings.update({
_id: 'theme-color-tertiary-font-color',
value: 'rgba(255, 255, 255, 0.6)',
}, {
diff --git a/server/startup/migrations/v070.js b/server/startup/migrations/v070.js
index 14eabbf7df3d..f3395590ade2 100644
--- a/server/startup/migrations/v070.js
+++ b/server/startup/migrations/v070.js
@@ -1,14 +1,17 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 70,
up() {
- const settings = RocketChat.models.Settings.find({ _id: /^Accounts_OAuth_Custom_.+/ }).fetch();
+ const settings = Settings.find({ _id: /^Accounts_OAuth_Custom_.+/ }).fetch();
for (const setting of settings) {
const { _id } = setting;
setting._id = setting._id.replace(/Accounts_OAuth_Custom_([A-Za-z0-9]+)_(.+)/, 'Accounts_OAuth_Custom-$1-$2');
setting._id = setting._id.replace(/Accounts_OAuth_Custom_([A-Za-z0-9]+)/, 'Accounts_OAuth_Custom-$1');
- RocketChat.models.Settings.remove({ _id });
- RocketChat.models.Settings.insert(setting);
+ Settings.remove({ _id });
+ Settings.insert(setting);
}
},
});
diff --git a/server/startup/migrations/v071.js b/server/startup/migrations/v071.js
index d69c78410865..36c3b45259ab 100644
--- a/server/startup/migrations/v071.js
+++ b/server/startup/migrations/v071.js
@@ -1,9 +1,12 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Messages } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 71,
up() {
// Removes the reactions on messages which are the system type "rm" ;)
- RocketChat.models.Messages.find({ t: 'rm', reactions: { $exists: true, $not: { $size: 0 } } }, { t: 1 }).forEach(function(message) {
- RocketChat.models.Messages.update({ _id: message._id }, { $set: { reactions: [] } });
+ Messages.find({ t: 'rm', reactions: { $exists: true, $not: { $size: 0 } } }, { t: 1 }).forEach(function(message) {
+ Messages.update({ _id: message._id }, { $set: { reactions: [] } });
});
},
});
diff --git a/server/startup/migrations/v072.js b/server/startup/migrations/v072.js
index 394f2c0a88e1..82e8220f17aa 100644
--- a/server/startup/migrations/v072.js
+++ b/server/startup/migrations/v072.js
@@ -1,8 +1,11 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 72,
up() {
- RocketChat.models.Users.find({ type: 'visitor', 'emails.address': { $exists: true } }, { emails: 1 }).forEach(function(visitor) {
- RocketChat.models.Users.update({ _id: visitor._id }, {
+ Users.find({ type: 'visitor', 'emails.address': { $exists: true } }, { emails: 1 }).forEach(function(visitor) {
+ Users.update({ _id: visitor._id }, {
$set: {
visitorEmails: visitor.emails,
},
diff --git a/server/startup/migrations/v073.js b/server/startup/migrations/v073.js
index 0e0337fb94b8..85a5746b3270 100644
--- a/server/startup/migrations/v073.js
+++ b/server/startup/migrations/v073.js
@@ -1,8 +1,11 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Users } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 73,
up() {
- RocketChat.models.Users.find({ 'oauth.athorizedClients': { $exists: true } }, { oauth: 1 }).forEach(function(user) {
- RocketChat.models.Users.update({ _id: user._id }, {
+ Users.find({ 'oauth.athorizedClients': { $exists: true } }, { oauth: 1 }).forEach(function(user) {
+ Users.update({ _id: user._id }, {
$set: {
'oauth.authorizedClients': user.oauth.athorizedClients,
},
diff --git a/server/startup/migrations/v074.js b/server/startup/migrations/v074.js
index c06397b81bcc..946ca44ebf3f 100644
--- a/server/startup/migrations/v074.js
+++ b/server/startup/migrations/v074.js
@@ -1,12 +1,15 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 74,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
- RocketChat.models.Settings.remove({ _id: 'Assets_favicon_64' });
- RocketChat.models.Settings.remove({ _id: 'Assets_favicon_96' });
- RocketChat.models.Settings.remove({ _id: 'Assets_favicon_128' });
- RocketChat.models.Settings.remove({ _id: 'Assets_favicon_256' });
- RocketChat.models.Settings.update({ _id: 'Assets_favicon_192' }, {
+ if (Settings) {
+ Settings.remove({ _id: 'Assets_favicon_64' });
+ Settings.remove({ _id: 'Assets_favicon_96' });
+ Settings.remove({ _id: 'Assets_favicon_128' });
+ Settings.remove({ _id: 'Assets_favicon_256' });
+ Settings.update({ _id: 'Assets_favicon_192' }, {
$set: {
i18nLabel: 'android-chrome 192x192 (png)',
},
diff --git a/server/startup/migrations/v075.js b/server/startup/migrations/v075.js
index 217862b689fe..850e4302b8d2 100644
--- a/server/startup/migrations/v075.js
+++ b/server/startup/migrations/v075.js
@@ -1,13 +1,14 @@
+import { Migrations } from 'meteor/rocketchat:migrations';
import { ServiceConfiguration } from 'meteor/service-configuration';
-RocketChat.Migrations.add({
+Migrations.add({
version: 71.1,
up() {
ServiceConfiguration.configurations.remove({});
},
});
-RocketChat.Migrations.add({
+Migrations.add({
version: 75,
up() {
ServiceConfiguration.configurations.remove({});
diff --git a/server/startup/migrations/v076.js b/server/startup/migrations/v076.js
index 54a81ac6f7c8..680a8b631fa6 100644
--- a/server/startup/migrations/v076.js
+++ b/server/startup/migrations/v076.js
@@ -1,9 +1,12 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Settings } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 76,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Settings) {
- RocketChat.models.Settings.find({ section: 'Colors (alphas)' }).forEach((setting) => {
- RocketChat.models.Settings.remove({ _id: setting._id });
+ if (Settings) {
+ Settings.find({ section: 'Colors (alphas)' }).forEach((setting) => {
+ Settings.remove({ _id: setting._id });
});
}
},
diff --git a/server/startup/migrations/v077.js b/server/startup/migrations/v077.js
index 975b91c8452e..49ab36f4924e 100644
--- a/server/startup/migrations/v077.js
+++ b/server/startup/migrations/v077.js
@@ -1,16 +1,19 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Rooms, Users } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 77,
up() {
- if (RocketChat && RocketChat.models && RocketChat.models.Rooms) {
- RocketChat.models.Rooms.find({
+ if (Rooms) {
+ Rooms.find({
t: 'l',
'v._id': { $exists: true },
'v.username': { $exists: false },
}, { fields: { 'v._id': 1 } }).forEach(function(room) {
- const user = RocketChat.models.Users.findOne({ _id: room.v._id }, { username: 1 });
+ const user = Users.findOne({ _id: room.v._id }, { username: 1 });
if (user && user.username) {
- RocketChat.models.Rooms.update({
+ Rooms.update({
_id: room._id,
}, {
$set: {
diff --git a/server/startup/migrations/v078.js b/server/startup/migrations/v078.js
index 0fed3e168a3b..bd697c825988 100644
--- a/server/startup/migrations/v078.js
+++ b/server/startup/migrations/v078.js
@@ -1,6 +1,9 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Permissions } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 78,
up() {
- RocketChat.models.Permissions.update({ _id: { $in: ['create-c', 'create-d', 'create-p'] } }, { $addToSet: { roles: 'bot' } }, { multi: true });
+ Permissions.update({ _id: { $in: ['create-c', 'create-d', 'create-p'] } }, { $addToSet: { roles: 'bot' } }, { multi: true });
},
});
diff --git a/server/startup/migrations/v079.js b/server/startup/migrations/v079.js
index 4b508f1f51fe..ccfa5769dcfd 100644
--- a/server/startup/migrations/v079.js
+++ b/server/startup/migrations/v079.js
@@ -1,11 +1,14 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Integrations } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 79,
up() {
- const integrations = RocketChat.models.Integrations.find({ type: 'webhook-incoming' }).fetch();
+ const integrations = Integrations.find({ type: 'webhook-incoming' }).fetch();
for (const integration of integrations) {
if (typeof integration.channel === 'string') {
- RocketChat.models.Integrations.update({ _id: integration._id }, {
+ Integrations.update({ _id: integration._id }, {
$set: {
channel: integration.channel.split(',').map((channel) => channel.trim()),
},
diff --git a/server/startup/migrations/v080.js b/server/startup/migrations/v080.js
index 7852347a92a4..d07fd736951b 100644
--- a/server/startup/migrations/v080.js
+++ b/server/startup/migrations/v080.js
@@ -1,4 +1,7 @@
-RocketChat.Migrations.add({
+import { Migrations } from 'meteor/rocketchat:migrations';
+import { Integrations } from 'meteor/rocketchat:models';
+
+Migrations.add({
version: 80,
up() {
const query = {
@@ -20,6 +23,6 @@ RocketChat.Migrations.add({
},
};
- RocketChat.models.Integrations.update(query, update, { multi: true });
+ Integrations.update(query, update, { multi: true });
},
});