mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 14:12:40 +00:00
remove migration in favor of as-edited approach
This commit is contained in:
@@ -176,7 +176,8 @@ app.get('/user/:username', async (req, res, next)=>{
|
||||
'editId',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'lastViewed'
|
||||
'lastViewed',
|
||||
'tags'
|
||||
];
|
||||
|
||||
let brews = await HomebrewModel.getByUser(req.params.username, ownAccount, fields)
|
||||
|
||||
@@ -124,7 +124,6 @@ const GoogleActions = {
|
||||
title : file.properties.title,
|
||||
description : file.description,
|
||||
views : parseInt(file.properties.views),
|
||||
tags : '',
|
||||
published : file.properties.published ? file.properties.published == 'true' : false,
|
||||
systems : [],
|
||||
thumbnail : file.properties.thumbnail
|
||||
|
||||
@@ -180,7 +180,6 @@ const updateBrew = async (req, res)=>{
|
||||
let afterSave = async ()=>true;
|
||||
|
||||
brew.text = mergeBrewText(brew);
|
||||
brew.tags = updateBrew.tags;
|
||||
|
||||
if(brew.googleId && removeFromGoogle) {
|
||||
// If the google id exists and we're removing it from google, set afterSave to delete the google brew and mark the brew's google id as undefined
|
||||
|
||||
@@ -68,26 +68,6 @@ HomebrewSchema.statics.getByUser = function(username, allowAccess=false, fields=
|
||||
|
||||
const Homebrew = mongoose.model('Homebrew', HomebrewSchema);
|
||||
|
||||
if(process.env.MIGRATE === 'true') {
|
||||
Homebrew.count({ tags: '' }, async (err, count)=>{
|
||||
if(!err) {
|
||||
if(count > 0) {
|
||||
Homebrew.updateMany({ tags: '' }, { tags: [] }, { multi: true }, function(err, data) {
|
||||
if(!err) {
|
||||
console.log('Successfully updated all brews to new schema definition');
|
||||
} else {
|
||||
console.log('An error occurred while updating brews to the new schema', err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('No brews to update');
|
||||
}
|
||||
} else {
|
||||
console.log('An error occurred while counting brews with the old schema', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
schema : HomebrewSchema,
|
||||
model : Homebrew,
|
||||
|
||||
Reference in New Issue
Block a user