summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAkihiko Odaki <nekomanma@pixiv.co.jp>2018-03-26 00:19:07 +0900
committerAkihiko Odaki <nekomanma@pixiv.co.jp>2018-03-26 14:07:16 +0900
commit19b9cb105d49e2a00ae19e3dc1f2d36dc394f148 (patch)
tree5faa9ad213bbf2efdcb4d06cf4fc941a501ab7f8 /tools
parentAllow to use domain whose prefix is not misskey (diff)
downloadsharkey-19b9cb105d49e2a00ae19e3dc1f2d36dc394f148.tar.gz
sharkey-19b9cb105d49e2a00ae19e3dc1f2d36dc394f148.tar.bz2
sharkey-19b9cb105d49e2a00ae19e3dc1f2d36dc394f148.zip
Introduce account document to user document
An account document is attached to a user document if an account of the user is on the server. It may be missing if the user is on a remote server.
Diffstat (limited to 'tools')
-rw-r--r--tools/migration/shell.1522038492.user-account.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/migration/shell.1522038492.user-account.js b/tools/migration/shell.1522038492.user-account.js
new file mode 100644
index 0000000000..056c29e8e1
--- /dev/null
+++ b/tools/migration/shell.1522038492.user-account.js
@@ -0,0 +1,41 @@
+db.users.dropIndex({ token: 1 });
+
+db.users.find({}).forEach(function(user) {
+ print(user._id);
+ db.users.update({ _id: user._id }, {
+ $unset: {
+ email: '',
+ links: '',
+ password: '',
+ token: '',
+ twitter: '',
+ line: '',
+ profile: '',
+ last_used_at: '',
+ is_bot: '',
+ is_pro: '',
+ two_factor_secret: '',
+ two_factor_enabled: '',
+ client_settings: '',
+ settings: ''
+ },
+ $set: {
+ account: {
+ email: user.email,
+ links: user.links,
+ password: user.password,
+ token: user.token,
+ twitter: user.twitter,
+ line: user.line,
+ profile: user.profile,
+ last_used_at: user.last_used_at,
+ is_bot: user.is_bot,
+ is_pro: user.is_pro,
+ two_factor_secret: user.two_factor_secret,
+ two_factor_enabled: user.two_factor_enabled,
+ client_settings: user.client_settings,
+ settings: user.settings
+ }
+ }
+ }, false, false);
+});