Merge pull request #29717 from overleaf/ii-subscpriptions-v1-id-index-history-v1
[web] Fix failing acceptance tests in history-v1 and github-sync GitOrigin-RevId: cae820598dfe7779386958fd759d3381b6007303
This commit is contained in:
@@ -17,6 +17,13 @@ const newIndexes = [
|
|||||||
sparse: true,
|
sparse: true,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
const tempIndex = [
|
||||||
|
{
|
||||||
|
key: { v1_id: 1 },
|
||||||
|
name: 'v1_id_temp_migration',
|
||||||
|
sparse: false, // Non-sparse so it includes null/missing values
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
async function removeNullV1Ids(collection) {
|
async function removeNullV1Ids(collection) {
|
||||||
// Remove the v1_id field from documents where it's null
|
// Remove the v1_id field from documents where it's null
|
||||||
@@ -64,14 +71,21 @@ async function assertNoDuplicateV1Ids(collection) {
|
|||||||
const migrate = async client => {
|
const migrate = async client => {
|
||||||
const { db } = client
|
const { db } = client
|
||||||
|
|
||||||
|
// Create temporary non-sparse index to allow queries with notablescan enabled
|
||||||
|
await Helpers.addIndexesToCollection(db.subscriptions, tempIndex)
|
||||||
|
|
||||||
// pre‑check (keep old index intact if failing)
|
// pre‑check (keep old index intact if failing)
|
||||||
await assertNoDuplicateV1Ids(db.subscriptions)
|
try {
|
||||||
await removeNullV1Ids(db.subscriptions)
|
await assertNoDuplicateV1Ids(db.subscriptions)
|
||||||
|
await removeNullV1Ids(db.subscriptions)
|
||||||
|
} catch (error) {
|
||||||
|
await Helpers.dropIndexesFromCollection(tempIndex)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
await Helpers.addIndexesToCollection(db.subscriptions, newIndexes)
|
await Helpers.addIndexesToCollection(db.subscriptions, newIndexes)
|
||||||
await Helpers.dropIndexesFromCollection(
|
await Helpers.dropIndexesFromCollection(
|
||||||
db.subscriptions,
|
db.subscriptions,
|
||||||
// drop the 20251010082205 index too which wasn't working properly
|
originalIndexes.concat({ name: 'v1_id_2' }).concat(tempIndex)
|
||||||
originalIndexes.concat({ name: 'v1_id_2' })
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user