-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unused fields, and collections, and indexes
- Loading branch information
1 parent
7084e6d
commit 5e538a8
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
graphql/migrations/20241017080000-article-passwords-cleanup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
exports.up = async function (db) { | ||
const mongo = await db._run("getDbInstance") | ||
const collections = (await mongo.listCollections().toArray()).map(c => c.name) | ||
|
||
|
||
// 1. remove article owners (moved into owner+contributors) | ||
await mongo.collection('articles').updateMany({}, { $unset: { owners: ''}}) | ||
|
||
// 2. remove linked collections relations | ||
await mongo.collection('users').updateMany({}, { $unset: { tokens: '', passwords: '' }}) | ||
|
||
// 3. remove Password related stuff | ||
if (collections.includes('passwords')) { | ||
await mongo.collection('passwords').drop() | ||
} | ||
|
||
// 4. remove Token related stuff | ||
if (collections.includes('tokens')) { | ||
await mongo.collection('tokens').drop() | ||
} | ||
|
||
return mongo.close() | ||
} | ||
|
||
exports.down = function (db) { | ||
Check failure on line 26 in graphql/migrations/20241017080000-article-passwords-cleanup.js GitHub Actions / build / build
|
||
return null | ||
} |