From c8977ab9d62150ad8411882cdb4f43545fd83c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Fern=C3=A1ndez=20Capel?= Date: Wed, 23 May 2018 15:23:46 +0100 Subject: [PATCH 1/2] Add overleaf id to user schema --- services/web/app/coffee/models/Subscription.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/web/app/coffee/models/Subscription.coffee b/services/web/app/coffee/models/Subscription.coffee index aaf78a4ab2..1e9ad71d83 100644 --- a/services/web/app/coffee/models/Subscription.coffee +++ b/services/web/app/coffee/models/Subscription.coffee @@ -18,6 +18,8 @@ SubscriptionSchema = new Schema downgraded: Boolean planCode: String allowed: {type: Boolean, default: true} + overleaf: + id: { type: Number } SubscriptionSchema.statics.findAndModify = (query, update, callback)-> From 8a55994f6484652e45b4e80d65da8eeea3ddacf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Fern=C3=A1ndez=20Capel?= Date: Wed, 23 May 2018 16:11:28 +0100 Subject: [PATCH 2/2] Ensure a team overleaf id is unique --- services/web/app/coffee/models/Subscription.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/models/Subscription.coffee b/services/web/app/coffee/models/Subscription.coffee index 1e9ad71d83..a9ebb7d585 100644 --- a/services/web/app/coffee/models/Subscription.coffee +++ b/services/web/app/coffee/models/Subscription.coffee @@ -19,7 +19,11 @@ SubscriptionSchema = new Schema planCode: String allowed: {type: Boolean, default: true} overleaf: - id: { type: Number } + id: + type: Number + index: + unique: true, + partialFilterExpression: {'overleaf.id': {$exists: true}} SubscriptionSchema.statics.findAndModify = (query, update, callback)->