From 26c979bcece39a81133eb42c3d043c8be9c028f1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:29:18 +0900 Subject: [PATCH] Better indexes --- src/models/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/user.ts b/src/models/user.ts index c121790c31..97b7a997e5 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -22,9 +22,9 @@ import SwSubscription, { deleteSwSubscription } from './sw-subscription'; const User = db.get('users'); -User.createIndex('username'); -User.createIndex('usernameLower'); -User.createIndex('token'); +User.createIndex(['username', 'host'], { unique: true }); +User.createIndex(['usernameLower', 'host'], { unique: true }); +User.createIndex('token', { unique: true }); User.createIndex('uri', { sparse: true, unique: true }); export default User;