mirror of
https://github.com/wekan/wekan.git
synced 2026-01-24 18:26:10 +01:00
Migrate createIndex to createIndexAsync
This commit is contained in:
parent
60ecddfce4
commit
ca2083c858
32 changed files with 112 additions and 110 deletions
|
|
@ -53,8 +53,8 @@ AccessibilitySettings.allow({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
AccessibilitySettings._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await AccessibilitySettings._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
const accessibilitySetting = AccessibilitySettings.findOne({});
|
||||
if (!accessibilitySetting) {
|
||||
AccessibilitySettings.insert({ enabled: false, sort: 0 });
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ AccountSettings.allow({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
AccountSettings._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await AccountSettings._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
AccountSettings.upsert(
|
||||
{ _id: 'accounts-allowEmailChange' },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ Actions.helpers({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
Actions._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await Actions._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,20 +83,20 @@ if (Meteor.isServer) {
|
|||
// For efficiency create indexes on the date of creation, and on the date of
|
||||
// creation in conjunction with the card or board id, as corresponding views
|
||||
// are largely used in the App. See #524.
|
||||
Meteor.startup(() => {
|
||||
Activities._collection.createIndex({ createdAt: -1 });
|
||||
Activities._collection.createIndex({ modifiedAt: -1 });
|
||||
Activities._collection.createIndex({ cardId: 1, createdAt: -1 });
|
||||
Activities._collection.createIndex({ boardId: 1, createdAt: -1 });
|
||||
Activities._collection.createIndex(
|
||||
Meteor.startup(async () => {
|
||||
await Activities._collection.createIndexAsync({ createdAt: -1 });
|
||||
await Activities._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await Activities._collection.createIndexAsync({ cardId: 1, createdAt: -1 });
|
||||
await Activities._collection.createIndexAsync({ boardId: 1, createdAt: -1 });
|
||||
await Activities._collection.createIndexAsync(
|
||||
{ commentId: 1 },
|
||||
{ partialFilterExpression: { commentId: { $exists: true } } },
|
||||
);
|
||||
Activities._collection.createIndex(
|
||||
await Activities._collection.createIndexAsync(
|
||||
{ attachmentId: 1 },
|
||||
{ partialFilterExpression: { attachmentId: { $exists: true } } },
|
||||
);
|
||||
Activities._collection.createIndex(
|
||||
await Activities._collection.createIndexAsync(
|
||||
{ customFieldId: 1 },
|
||||
{ partialFilterExpression: { customFieldId: { $exists: true } } },
|
||||
);
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ Announcements.allow({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
Announcements._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await Announcements._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
const announcements = Announcements.findOne({});
|
||||
if (!announcements) {
|
||||
Announcements.insert({ enabled: false, sort: 0 });
|
||||
|
|
|
|||
|
|
@ -367,8 +367,8 @@ if (Meteor.isServer) {
|
|||
},
|
||||
});
|
||||
|
||||
Meteor.startup(() => {
|
||||
Attachments.collection.createIndex({ 'meta.cardId': 1 });
|
||||
Meteor.startup(async () => {
|
||||
await Attachments.collection.createIndexAsync({ 'meta.cardId': 1 });
|
||||
const storagePath = fileStoreStrategyFactory.storagePath;
|
||||
if (!fs.existsSync(storagePath)) {
|
||||
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||
|
|
|
|||
|
|
@ -2088,16 +2088,16 @@ Boards.before.insert((userId, doc) => {
|
|||
|
||||
if (Meteor.isServer) {
|
||||
// Let MongoDB ensure that a member is not included twice in the same board
|
||||
Meteor.startup(() => {
|
||||
Boards._collection.createIndex({ modifiedAt: -1 });
|
||||
Boards._collection.createIndex(
|
||||
Meteor.startup(async () => {
|
||||
await Boards._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await Boards._collection.createIndexAsync(
|
||||
{
|
||||
_id: 1,
|
||||
'members.userId': 1,
|
||||
},
|
||||
{ unique: true },
|
||||
);
|
||||
Boards._collection.createIndex({ 'members.userId': 1 });
|
||||
await Boards._collection.createIndexAsync({ 'members.userId': 1 });
|
||||
});
|
||||
|
||||
// Genesis: the first activity of the newly created board
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ CardCommentReactions.allow({
|
|||
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
CardCommentReactions._collection.createIndex({ cardCommentId: 1 }, { unique: true });
|
||||
Meteor.startup(async () => {
|
||||
await CardCommentReactions._collection.createIndexAsync({ cardCommentId: 1 }, { unique: true });
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,9 +192,9 @@ CardComments.textSearch = (userId, textArray) => {
|
|||
if (Meteor.isServer) {
|
||||
// Comments are often fetched within a card, so we create an index to make these
|
||||
// queries more efficient.
|
||||
Meteor.startup(() => {
|
||||
CardComments._collection.createIndex({ modifiedAt: -1 });
|
||||
CardComments._collection.createIndex({ cardId: 1, createdAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await CardComments._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await CardComments._collection.createIndexAsync({ cardId: 1, createdAt: -1 });
|
||||
});
|
||||
|
||||
CardComments.after.insert((userId, doc) => {
|
||||
|
|
|
|||
|
|
@ -3477,15 +3477,15 @@ if (Meteor.isServer) {
|
|||
});
|
||||
// Cards are often fetched within a board, so we create an index to make these
|
||||
// queries more efficient.
|
||||
Meteor.startup(() => {
|
||||
Cards._collection.createIndex({ modifiedAt: -1 });
|
||||
Cards._collection.createIndex({ boardId: 1, createdAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await Cards._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await Cards._collection.createIndexAsync({ boardId: 1, createdAt: -1 });
|
||||
// https://github.com/wekan/wekan/issues/1863
|
||||
// Swimlane added a new field in the cards collection of mongodb named parentId.
|
||||
// When loading a board, mongodb is searching for every cards, the id of the parent (in the swinglanes collection).
|
||||
// With a huge database, this result in a very slow app and high CPU on the mongodb side.
|
||||
// To correct it, add Index to parentId:
|
||||
Cards._collection.createIndex({ parentId: 1 });
|
||||
await Cards._collection.createIndexAsync({ parentId: 1 });
|
||||
// let notifydays = parseInt(process.env.NOTIFY_DUE_DAYS_BEFORE_AND_AFTER) || 2; // default as 2 days b4 and after
|
||||
// let notifyitvl = parseInt(process.env.NOTIFY_DUE_AT_HOUR_OF_DAY) || 3600 * 24 * 1e3; // default interval as one day
|
||||
// Meteor.call("findDueCards",notifydays,notifyitvl);
|
||||
|
|
|
|||
|
|
@ -217,10 +217,10 @@ function publishChekListUncompleted(userId, doc) {
|
|||
|
||||
// Activities
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
ChecklistItems._collection.createIndex({ modifiedAt: -1 });
|
||||
ChecklistItems._collection.createIndex({ checklistId: 1 });
|
||||
ChecklistItems._collection.createIndex({ cardId: 1 });
|
||||
Meteor.startup(async () => {
|
||||
await ChecklistItems._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await ChecklistItems._collection.createIndexAsync({ checklistId: 1 });
|
||||
await ChecklistItems._collection.createIndexAsync({ cardId: 1 });
|
||||
});
|
||||
|
||||
ChecklistItems.after.update((userId, doc, fieldNames) => {
|
||||
|
|
|
|||
|
|
@ -286,9 +286,9 @@ if (Meteor.isServer) {
|
|||
},
|
||||
});
|
||||
|
||||
Meteor.startup(() => {
|
||||
Checklists._collection.createIndex({ modifiedAt: -1 });
|
||||
Checklists._collection.createIndex({ cardId: 1, createdAt: 1 });
|
||||
Meteor.startup(async () => {
|
||||
await Checklists._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await Checklists._collection.createIndexAsync({ cardId: 1, createdAt: 1 });
|
||||
});
|
||||
|
||||
Checklists.after.insert((userId, doc) => {
|
||||
|
|
|
|||
|
|
@ -232,9 +232,9 @@ function customFieldEdit(userId, doc) {
|
|||
}
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
CustomFields._collection.createIndex({ modifiedAt: -1 });
|
||||
CustomFields._collection.createIndex({ boardIds: 1 });
|
||||
Meteor.startup(async () => {
|
||||
await CustomFields._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await CustomFields._collection.createIndexAsync({ boardIds: 1 });
|
||||
});
|
||||
|
||||
CustomFields.after.insert((userId, doc) => {
|
||||
|
|
|
|||
|
|
@ -122,9 +122,9 @@ Integrations.allow({
|
|||
|
||||
//INTEGRATIONS REST API
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
Integrations._collection.createIndex({ modifiedAt: -1 });
|
||||
Integrations._collection.createIndex({ boardId: 1 });
|
||||
Meteor.startup(async () => {
|
||||
await Integrations._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await Integrations._collection.createIndexAsync({ boardId: 1 });
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ InvitationCodes.helpers({
|
|||
// });
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
InvitationCodes._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await InvitationCodes._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
});
|
||||
Boards.deny({
|
||||
fetch: ['members'],
|
||||
|
|
|
|||
|
|
@ -561,10 +561,10 @@ Meteor.methods({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
Lists._collection.rawCollection().createIndex({ modifiedAt: -1 });
|
||||
Lists._collection.rawCollection().createIndex({ boardId: 1 });
|
||||
Lists._collection.rawCollection().createIndex({ archivedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await Lists._collection.rawCollection().createIndex({ modifiedAt: -1 });
|
||||
await Lists._collection.rawCollection().createIndex({ boardId: 1 });
|
||||
await Lists._collection.rawCollection().createIndex({ archivedAt: -1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ LockoutSettings.allow({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
LockoutSettings._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await LockoutSettings._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
|
||||
// Known users settings
|
||||
LockoutSettings.upsert(
|
||||
|
|
|
|||
|
|
@ -292,9 +292,9 @@ if (Meteor.isServer) {
|
|||
|
||||
if (Meteor.isServer) {
|
||||
// Index for Organization name.
|
||||
Meteor.startup(() => {
|
||||
// Org._collection.createIndex({ name: -1 });
|
||||
Org._collection.createIndex({ orgDisplayName: 1 });
|
||||
Meteor.startup(async () => {
|
||||
// Org._collection.createIndexAsync({ name: -1 });
|
||||
await Org._collection.createIndexAsync({ orgDisplayName: 1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ OrgUser.attachSchema(
|
|||
|
||||
if (Meteor.isServer) {
|
||||
// Index for Organization User.
|
||||
Meteor.startup(() => {
|
||||
OrgUser._collection.createIndex({ orgId: -1 });
|
||||
OrgUser._collection.createIndex({ orgId: -1, userId: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await OrgUser._collection.createIndexAsync({ orgId: -1 });
|
||||
await OrgUser._collection.createIndexAsync({ orgId: -1, userId: -1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,10 +160,10 @@ PositionHistory.helpers({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
PositionHistory._collection.createIndex({ boardId: 1, entityType: 1, entityId: 1 });
|
||||
PositionHistory._collection.createIndex({ boardId: 1, entityType: 1 });
|
||||
PositionHistory._collection.createIndex({ createdAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await PositionHistory._collection.createIndexAsync({ boardId: 1, entityType: 1, entityId: 1 });
|
||||
await PositionHistory._collection.createIndexAsync({ boardId: 1, entityType: 1 });
|
||||
await PositionHistory._collection.createIndexAsync({ createdAt: -1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ Rules.allow({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
Rules._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await Rules._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -202,8 +202,8 @@ Settings.allow({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
Settings._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await Settings._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
const setting = ReactiveCache.getCurrentSetting();
|
||||
if (!setting) {
|
||||
const now = new Date();
|
||||
|
|
|
|||
|
|
@ -378,9 +378,9 @@ Swimlanes.archivedSwimlaneIds = () => {
|
|||
Swimlanes.hookOptions.after.update = { fetchPrevious: false };
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
Swimlanes._collection.createIndex({ modifiedAt: -1 });
|
||||
Swimlanes._collection.createIndex({ boardId: 1 });
|
||||
Meteor.startup(async () => {
|
||||
await Swimlanes._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await Swimlanes._collection.createIndexAsync({ boardId: 1 });
|
||||
});
|
||||
|
||||
Swimlanes.after.insert((userId, doc) => {
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ TableVisibilityModeSettings.allow({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
TableVisibilityModeSettings._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await TableVisibilityModeSettings._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
TableVisibilityModeSettings.upsert(
|
||||
{ _id: 'tableVisibilityMode-allowPrivateOnly' },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -259,8 +259,8 @@ if (Meteor.isServer) {
|
|||
|
||||
if (Meteor.isServer) {
|
||||
// Index for Team name.
|
||||
Meteor.startup(() => {
|
||||
Team._collection.createIndex({ teamDisplayName: 1 });
|
||||
Meteor.startup(async () => {
|
||||
await Team._collection.createIndexAsync({ teamDisplayName: 1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ if (Meteor.isServer) {
|
|||
|
||||
if (Meteor.isServer) {
|
||||
// Index for Organization User.
|
||||
Meteor.startup(() => {
|
||||
Translation._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await Translation._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ Triggers.helpers({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
Triggers._collection.createIndex({ modifiedAt: -1 });
|
||||
Meteor.startup(async () => {
|
||||
await Triggers._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ if (Meteor.isServer) {
|
|||
function isAuthor(userId, doc, fieldNames = []) {
|
||||
return userId === doc.userId && fieldNames.indexOf('userId') === -1;
|
||||
}
|
||||
Meteor.startup(() => {
|
||||
UnsavedEditCollection._collection.createIndex({ modifiedAt: -1 });
|
||||
UnsavedEditCollection._collection.createIndex({ userId: 1 });
|
||||
Meteor.startup(async () => {
|
||||
await UnsavedEditCollection._collection.createIndexAsync({ modifiedAt: -1 });
|
||||
await UnsavedEditCollection._collection.createIndexAsync({ userId: 1 });
|
||||
});
|
||||
UnsavedEditCollection.allow({
|
||||
insert: isAuthor,
|
||||
|
|
|
|||
|
|
@ -286,12 +286,12 @@ UserPositionHistory.helpers({
|
|||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.startup(() => {
|
||||
UserPositionHistory._collection.createIndex({ userId: 1, boardId: 1, createdAt: -1 });
|
||||
UserPositionHistory._collection.createIndex({ userId: 1, entityType: 1, entityId: 1 });
|
||||
UserPositionHistory._collection.createIndex({ userId: 1, isCheckpoint: 1 });
|
||||
UserPositionHistory._collection.createIndex({ batchId: 1 });
|
||||
UserPositionHistory._collection.createIndex({ createdAt: 1 }); // For cleanup of old entries
|
||||
Meteor.startup(async () => {
|
||||
await UserPositionHistory._collection.createIndexAsync({ userId: 1, boardId: 1, createdAt: -1 });
|
||||
await UserPositionHistory._collection.createIndexAsync({ userId: 1, entityType: 1, entityId: 1 });
|
||||
await UserPositionHistory._collection.createIndexAsync({ userId: 1, isCheckpoint: 1 });
|
||||
await UserPositionHistory._collection.createIndexAsync({ batchId: 1 });
|
||||
await UserPositionHistory._collection.createIndexAsync({ createdAt: 1 }); // For cleanup of old entries
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2895,11 +2895,11 @@ const addCronJob = _.debounce(
|
|||
|
||||
if (Meteor.isServer) {
|
||||
// Let mongoDB ensure username unicity
|
||||
Meteor.startup(() => {
|
||||
allowedSortValues.forEach((value) => {
|
||||
Lists._collection.createIndex(value);
|
||||
});
|
||||
Users._collection.createIndex({
|
||||
Meteor.startup(async () => {
|
||||
for (const value of allowedSortValues) {
|
||||
await Lists._collection.createIndexAsync(value);
|
||||
}
|
||||
await Users._collection.createIndexAsync({
|
||||
modifiedAt: -1,
|
||||
});
|
||||
// Avatar URLs from CollectionFS to Meteor-Files, at users collection avatarUrl field:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue