-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #442 from sparcs-kaist/dev
Main branch update from Dev branch
- Loading branch information
Showing
9 changed files
with
391 additions
and
359 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,36 @@ | ||
// Issue #173을 해결하기 위한 DB 마이그레이션 스크립트입니다. | ||
// https://github.com/sparcs-kaist/taxi-back/issues/173 | ||
|
||
const { MongoClient } = require("mongodb"); | ||
const { mongo: mongoUrl, aws: awsEnv } = require("../loadenv"); | ||
|
||
const time = Date.now(); | ||
|
||
const client = new MongoClient(mongoUrl); | ||
const db = client.db("taxi"); | ||
const users = db.collection("users"); | ||
|
||
async function run() { | ||
try { | ||
for await (const doc of users.find()) { | ||
// 이미 변환이 완료된 경우에는 Pass합니다. | ||
if (doc.profileImageUrl.startsWith(awsEnv.s3Url)) continue; | ||
|
||
await users.findOneAndUpdate( | ||
{ _id: doc._id }, | ||
{ | ||
$set: { | ||
profileImageUrl: `${awsEnv.s3Url}/profile-img/${doc.profileImageUrl}?token=${time}`, | ||
}, | ||
} | ||
); | ||
} | ||
} catch (err) { | ||
console.log(err); | ||
} finally { | ||
await client.close(); | ||
} | ||
} | ||
run().then(() => { | ||
console.log("Done!"); | ||
}); |
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
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
Oops, something went wrong.