mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #15562 from overleaf/em-drop-unused-indexes
Drop unused indexes GitOrigin-RevId: 7658a8545f6068347276f3cdf1e742ee34a491d9
This commit is contained in:
parent
d45ca7d401
commit
348bdf7907
2 changed files with 109 additions and 0 deletions
|
@ -0,0 +1,73 @@
|
|||
const Helpers = require('./lib/helpers')
|
||||
|
||||
exports.tags = ['server-ce', 'server-pro', 'saas']
|
||||
|
||||
const PROJECTS_INDEXES = [
|
||||
{
|
||||
name: 'publicAccesLevel_1',
|
||||
key: { publicAccesLevel: 1 },
|
||||
},
|
||||
{
|
||||
name: 'name_1',
|
||||
key: { name: 1 },
|
||||
},
|
||||
{
|
||||
name: 'brandVariationId_1',
|
||||
key: { brandVariationId: 1 },
|
||||
},
|
||||
]
|
||||
|
||||
const DOC_SNAPSHOTS_INDEXES = [
|
||||
{
|
||||
name: 'project_id_1',
|
||||
key: { project_id: 1 },
|
||||
},
|
||||
]
|
||||
|
||||
const USERS_INDEXES = [
|
||||
{
|
||||
name: 'owner_ref',
|
||||
key: { owner_ref: 1 },
|
||||
},
|
||||
{
|
||||
name: 'has dropbox',
|
||||
key: { 'dropbox.access_token.oauth_token_secret': 1 },
|
||||
},
|
||||
{
|
||||
name: 'holdingAccount_1',
|
||||
key: { holdingAccount: 1 },
|
||||
},
|
||||
{
|
||||
name: 'subscription.freeTrialDowngraded_1',
|
||||
key: { 'subscription.freeTrialDowngraded': 1 },
|
||||
},
|
||||
{
|
||||
name: 'password_and_email',
|
||||
key: { password: 1, email: 1 },
|
||||
},
|
||||
{
|
||||
name: 'subscription.freeTrialExpiresAt_1',
|
||||
key: { 'subscription.freeTrialExpiresAt': 1 },
|
||||
},
|
||||
{
|
||||
name: 'auth_token_1',
|
||||
key: { auth_token: 1 },
|
||||
},
|
||||
]
|
||||
|
||||
exports.migrate = async client => {
|
||||
const { db } = client
|
||||
await Helpers.dropIndexesFromCollection(db.projects, PROJECTS_INDEXES)
|
||||
await Helpers.dropIndexesFromCollection(
|
||||
db.docSnapshots,
|
||||
DOC_SNAPSHOTS_INDEXES
|
||||
)
|
||||
await Helpers.dropIndexesFromCollection(db.users, USERS_INDEXES)
|
||||
}
|
||||
|
||||
exports.rollback = async client => {
|
||||
const { db } = client
|
||||
await Helpers.addIndexesToCollection(db.projects, PROJECTS_INDEXES)
|
||||
await Helpers.addIndexesToCollection(db.docSnapshots, DOC_SNAPSHOTS_INDEXES)
|
||||
await Helpers.addIndexesToCollection(db.users, USERS_INDEXES)
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
const Helpers = require('./lib/helpers')
|
||||
|
||||
exports.tags = ['saas']
|
||||
|
||||
const SUBSCRIPTIONS_INDEXES = [
|
||||
{
|
||||
name: 'free_trial',
|
||||
key: { 'freeTrial.downgraded': 1, 'freeTrial.expiresAt': 1 },
|
||||
},
|
||||
]
|
||||
|
||||
const USERS_INDEXES = [
|
||||
{
|
||||
name: 'labsProgram_1',
|
||||
key: { labsProgram: 1 },
|
||||
},
|
||||
{
|
||||
name: 'labsProgramGalileo_1',
|
||||
key: { labsProgramGalileo: 1 },
|
||||
},
|
||||
]
|
||||
|
||||
exports.migrate = async client => {
|
||||
const { db } = client
|
||||
await Helpers.dropIndexesFromCollection(
|
||||
db.subscriptions,
|
||||
SUBSCRIPTIONS_INDEXES
|
||||
)
|
||||
await Helpers.dropIndexesFromCollection(db.users, USERS_INDEXES)
|
||||
}
|
||||
|
||||
exports.rollback = async client => {
|
||||
const { db } = client
|
||||
await Helpers.addIndexesToCollection(db.subscriptions, SUBSCRIPTIONS_INDEXES)
|
||||
await Helpers.addIndexesToCollection(db.users, USERS_INDEXES)
|
||||
}
|
Loading…
Reference in a new issue