diff options
| author | otofune <otofune@gmail.com> | 2017-11-07 09:58:02 +0900 |
|---|---|---|
| committer | otofune <otofune@gmail.com> | 2017-11-07 09:58:02 +0900 |
| commit | 696cd3b0e35673966c9aee5089c9a821b9e00d04 (patch) | |
| tree | 3d5a3fcc5086c0487f2b4df3bf17bad92848d698 /tools | |
| parent | gulpfile - shutdown mocha after test run (diff) | |
| download | misskey-696cd3b0e35673966c9aee5089c9a821b9e00d04.tar.gz misskey-696cd3b0e35673966c9aee5089c9a821b9e00d04.tar.bz2 misskey-696cd3b0e35673966c9aee5089c9a821b9e00d04.zip | |
migration - add migration to support changed filename usage
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/migration/change-gridfs-metadata-name-to-filename.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/migration/change-gridfs-metadata-name-to-filename.js b/tools/migration/change-gridfs-metadata-name-to-filename.js new file mode 100644 index 0000000000..0d9e977c6e --- /dev/null +++ b/tools/migration/change-gridfs-metadata-name-to-filename.js @@ -0,0 +1,30 @@ +// for Node.js interpret +/** + * change usage of GridFS filename + * see commit fb422b4d603c53a70712caba55b35a48a8c2e619 + */ + +const { default: DriveFile } = require('../../built/api/models/drive-file') + +async function applyNewChange (doc) { + const result = await DriveFile.update(doc._id, { + $set: { + filename: doc.metadata.name + }, + $unset: { + 'metadata.name': '' + } + }) + return result.ok === 1 +} + +async function main () { + const oldTypeDocs = await DriveFile.find({ + 'metadata.name': { + $exists: true + } + }) + return await Promise.all(oldTypeDocs.map(applyNewChange)) +} + +main().then(console.dir).catch(console.error) |