Skip to content

Commit

Permalink
Merge pull request #431 from synapsestudios/fix-migration
Browse files Browse the repository at this point in the history
fix migration
  • Loading branch information
bobeagan authored Apr 12, 2019
2 parents cf2b315 + a58a964 commit 7b41d91
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions api/migrations/20190312161838_image-rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ exports.up = async knex => {
CopySource: `/${s3Bucket}${parsedPictureLocation.pathname}`,
Key: newPath,
};
await s3.copyObject(copyParams).promise();

users[i].profile.picture = `https://${s3Bucket}.s3.amazonaws.com/${newPath}`;
try {
await s3.copyObject(copyParams).promise();

await knex('SIP_user')
.where('id', users[i].id)
.update({ profile: users[i].profile });
users[i].profile.picture = `https://${s3Bucket}.s3.amazonaws.com/${newPath}`;

await knex('SIP_user')
.where('id', users[i].id)
.update({ profile: users[i].profile });
} catch(e) {
// swallow and move on
}
}
}

Expand Down

0 comments on commit 7b41d91

Please sign in to comment.