Skip to content

Commit

Permalink
Update migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Jun 26, 2023
1 parent 6204216 commit 6dc95a4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
22 changes: 21 additions & 1 deletion graphql/data/20230505-tag-color-hex.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,27 @@ while (cursor.hasNext()) {
{ _id: tag._id },
{
$set: {
color: colours[tag.color] || '#eee',
color: colours[tag.color] || '#eeeeee',
},
},
{ upsert: false }
)
} else if (tag.color && tag.color.length < 7) {
db.tags.updateOne(
{ _id: tag._id },
{
$set: {
color: '#cccccc',
},
},
{ upsert: false }
)
} else if (!tag.color) {
db.tags.updateOne(
{ _id: tag._id },
{
$set: {
color: '#eeeeee',
},
},
{ upsert: false }
Expand Down
24 changes: 24 additions & 0 deletions graphql/data/20230626-version-owner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const conn = Mongo()
const session = conn.startSession()

session.startTransaction()

const cursor = db.versions.find({"owner": null })
while (cursor.hasNext()) {
const version = cursor.next()
const articleId = version.article
const article = db.articles.findOne({_id: articleId})
if (article !== null && article.owner !== null) {
db.versions.updateOne(
{ _id: version._id },
{
$set: {
owner: article.owner,
},
},
{ upsert: false }
)
}
}

session.commitTransaction()

0 comments on commit 6dc95a4

Please sign in to comment.