mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-17 19:12:33 -05:00
Document missing database schema indexes
These indexes are on the production database but not set in our mongoose schemas.
This commit is contained in:
parent
2a8bc40c02
commit
3d32c8a5e7
16 changed files with 189 additions and 3 deletions
|
@ -15,6 +15,22 @@ AchievementSchema = new mongoose.Schema({
|
|||
userField: String
|
||||
}, {strict: false})
|
||||
|
||||
AchievementSchema.index(
|
||||
{
|
||||
_fts: 'text'
|
||||
_ftsx: 1
|
||||
},
|
||||
{
|
||||
name: 'search index'
|
||||
sparse: true
|
||||
weights: {name: 1}
|
||||
default_language: 'english'
|
||||
'language_override': 'language'
|
||||
'textIndexVersion': 2
|
||||
})
|
||||
AchievementSchema.index({i18nCoverage: 1}, {name: 'translation coverage index', sparse: true})
|
||||
AchievementSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
|
||||
|
||||
AchievementSchema.methods.objectifyQuery = ->
|
||||
try
|
||||
@set('query', JSON.parse(@get('query'))) if typeof @get('query') == 'string'
|
||||
|
|
|
@ -11,6 +11,7 @@ AnalyticsLogEventSchema = new mongoose.Schema({
|
|||
event: String
|
||||
properties: mongoose.Schema.Types.Mixed
|
||||
}, {strict: false})
|
||||
|
||||
AnalyticsLogEventSchema.index({event: 1, _id: 1})
|
||||
|
||||
module.exports = AnalyticsLogEvent = mongoose.model('analytics.log.event', AnalyticsLogEventSchema)
|
||||
|
|
|
@ -7,4 +7,7 @@ AnalyticsUsersActiveSchema = new mongoose.Schema({
|
|||
'default': Date.now
|
||||
}, {strict: false})
|
||||
|
||||
AnalyticsUsersActiveSchema.index({created: 1})
|
||||
AnalyticsUsersActiveSchema.index({creator: 1})
|
||||
|
||||
module.exports = AnalyticsUsersActive = mongoose.model('analytics.users.active', AnalyticsUsersActiveSchema)
|
||||
|
|
|
@ -3,6 +3,32 @@ plugins = require '../plugins/plugins'
|
|||
|
||||
ArticleSchema = new mongoose.Schema(body: String, {strict: false})
|
||||
|
||||
ArticleSchema.index(
|
||||
{
|
||||
index: 1
|
||||
_fts: 'text'
|
||||
_ftsx: 1
|
||||
},
|
||||
{
|
||||
name: 'search index'
|
||||
sparse: true
|
||||
weights: {body: 1, name: 1}
|
||||
default_language: 'english'
|
||||
'language_override': 'searchLanguage'
|
||||
'textIndexVersion': 2
|
||||
})
|
||||
ArticleSchema.index(
|
||||
{
|
||||
original: 1
|
||||
'version.major': -1
|
||||
'version.minor': -1
|
||||
},
|
||||
{
|
||||
name: 'version index'
|
||||
unique: true
|
||||
})
|
||||
ArticleSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
|
||||
|
||||
ArticleSchema.plugin(plugins.NamedPlugin)
|
||||
ArticleSchema.plugin(plugins.VersionedPlugin)
|
||||
ArticleSchema.plugin(plugins.SearchablePlugin, {searchable: ['body', 'name']})
|
||||
|
|
|
@ -3,6 +3,9 @@ plugins = require '../plugins/plugins'
|
|||
|
||||
CampaignSchema = new mongoose.Schema(body: String, {strict: false})
|
||||
|
||||
CampaignSchema.index({i18nCoverage: 1}, {name: 'translation coverage index', sparse: true})
|
||||
CampaignSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
|
||||
|
||||
CampaignSchema.plugin(plugins.NamedPlugin)
|
||||
CampaignSchema.plugin(plugins.TranslationCoveragePlugin)
|
||||
|
||||
|
|
|
@ -6,6 +6,32 @@ LevelSchema = new mongoose.Schema({
|
|||
description: String
|
||||
}, {strict: false})
|
||||
|
||||
LevelSchema.index(
|
||||
{
|
||||
index: 1
|
||||
_fts: 'text'
|
||||
_ftsx: 1
|
||||
},
|
||||
{
|
||||
name: 'search index'
|
||||
sparse: true
|
||||
weights: {description: 1, name: 1}
|
||||
default_language: 'english'
|
||||
'language_override': 'searchLanguage'
|
||||
'textIndexVersion': 2
|
||||
})
|
||||
LevelSchema.index(
|
||||
{
|
||||
original: 1
|
||||
'version.major': -1
|
||||
'version.minor': -1
|
||||
},
|
||||
{
|
||||
name: 'version index'
|
||||
unique: true
|
||||
})
|
||||
LevelSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
|
||||
|
||||
LevelSchema.plugin(plugins.NamedPlugin)
|
||||
LevelSchema.plugin(plugins.PermissionsPlugin)
|
||||
LevelSchema.plugin(plugins.VersionedPlugin)
|
||||
|
|
|
@ -7,6 +7,32 @@ LevelComponentSchema = new mongoose.Schema {
|
|||
system: String
|
||||
}, {strict: false}
|
||||
|
||||
LevelComponentSchema.index(
|
||||
{
|
||||
index: 1
|
||||
_fts: 'text'
|
||||
_ftsx: 1
|
||||
},
|
||||
{
|
||||
name: 'search index'
|
||||
sparse: true
|
||||
weights: {description: 1, name: 1, searchStrings: 1}
|
||||
default_language: 'english'
|
||||
'language_override': 'searchLanguage'
|
||||
'textIndexVersion': 2
|
||||
})
|
||||
LevelComponentSchema.index(
|
||||
{
|
||||
original: 1
|
||||
'version.major': -1
|
||||
'version.minor': -1
|
||||
},
|
||||
{
|
||||
name: 'version index'
|
||||
unique: true
|
||||
})
|
||||
LevelComponentSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
|
||||
|
||||
LevelComponentSchema.plugin plugins.NamedPlugin
|
||||
LevelComponentSchema.plugin plugins.PermissionsPlugin
|
||||
LevelComponentSchema.plugin plugins.VersionedPlugin
|
||||
|
|
|
@ -10,4 +10,7 @@ LevelFeedbackSchema = new mongoose.Schema({
|
|||
'default': Date.now
|
||||
}, {strict: false})
|
||||
|
||||
LevelFeedbackSchema.index({created: 1})
|
||||
LevelFeedbackSchema.index({creator: 1})
|
||||
|
||||
module.exports = LevelFeedback = mongoose.model('level.feedback', LevelFeedbackSchema)
|
||||
|
|
|
@ -11,6 +11,20 @@ LevelSessionSchema = new mongoose.Schema({
|
|||
type: Date
|
||||
'default': Date.now
|
||||
}, {strict: false})
|
||||
|
||||
LevelSessionSchema.index({creator: 1})
|
||||
LevelSessionSchema.index({level: 1})
|
||||
LevelSessionSchema.index({levelID: 1})
|
||||
LevelSessionSchema.index({'level.majorVersion': 1})
|
||||
LevelSessionSchema.index({'level.original': 1}, {name: 'Level Original'})
|
||||
LevelSessionSchema.index({'level.original': 1, 'level.majorVersion': 1, 'creator': 1, 'team': 1})
|
||||
LevelSessionSchema.index({playtime: 1}, {name: 'Playtime'})
|
||||
LevelSessionSchema.index({submitDate: 1})
|
||||
LevelSessionSchema.index({submitted: 1}, {sparse: true})
|
||||
LevelSessionSchema.index({team: 1}, {sparse: true})
|
||||
LevelSessionSchema.index({totalScore: 1}, {sparse: true})
|
||||
LevelSessionSchema.index({user: 1, changed: -1}, {name: 'last played index', sparse: true})
|
||||
|
||||
LevelSessionSchema.plugin(plugins.PermissionsPlugin)
|
||||
LevelSessionSchema.plugin(AchievablePlugin)
|
||||
|
||||
|
|
|
@ -6,6 +6,32 @@ LevelSystemSchema = new mongoose.Schema {
|
|||
description: String
|
||||
}, {strict: false}
|
||||
|
||||
LevelSystemSchema.index(
|
||||
{
|
||||
index: 1
|
||||
_fts: 'text'
|
||||
_ftsx: 1
|
||||
},
|
||||
{
|
||||
name: 'search index'
|
||||
sparse: true
|
||||
weights: {description: 1, name: 1, name: 1}
|
||||
default_language: 'english'
|
||||
'language_override': 'searchLanguage'
|
||||
'textIndexVersion': 2
|
||||
})
|
||||
LevelSystemSchema.index(
|
||||
{
|
||||
original: 1
|
||||
'version.major': -1
|
||||
'version.minor': -1
|
||||
},
|
||||
{
|
||||
name: 'version index'
|
||||
unique: true
|
||||
})
|
||||
LevelSystemSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
|
||||
|
||||
LevelSystemSchema.plugin(plugins.NamedPlugin)
|
||||
LevelSystemSchema.plugin(plugins.PermissionsPlugin)
|
||||
LevelSystemSchema.plugin(plugins.VersionedPlugin)
|
||||
|
|
|
@ -5,6 +5,32 @@ ThangTypeSchema = new mongoose.Schema({
|
|||
body: String,
|
||||
}, {strict: false})
|
||||
|
||||
ThangTypeSchema.index(
|
||||
{
|
||||
index: 1
|
||||
_fts: 'text'
|
||||
_ftsx: 1
|
||||
},
|
||||
{
|
||||
name: 'search index'
|
||||
sparse: true
|
||||
weights: {name: 1}
|
||||
default_language: 'english'
|
||||
'language_override': 'searchLanguage'
|
||||
'textIndexVersion': 2
|
||||
})
|
||||
ThangTypeSchema.index(
|
||||
{
|
||||
original: 1
|
||||
'version.major': -1
|
||||
'version.minor': -1
|
||||
},
|
||||
{
|
||||
name: 'version index'
|
||||
unique: true
|
||||
})
|
||||
ThangTypeSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})
|
||||
|
||||
ThangTypeSchema.plugin plugins.NamedPlugin
|
||||
ThangTypeSchema.plugin plugins.VersionedPlugin
|
||||
ThangTypeSchema.plugin plugins.SearchablePlugin, {searchable: ['name']}
|
||||
|
|
|
@ -8,4 +8,6 @@ MailSent = new mongoose.Schema({
|
|||
'default': Date.now
|
||||
}, {strict: false})
|
||||
|
||||
MailSent.index({user: 1}, {name: 'User'})
|
||||
|
||||
module.exports = MailSent = mongoose.model('mail.sent', MailSent)
|
||||
|
|
|
@ -9,4 +9,6 @@ ScoringTaskSchema = new mongoose.Schema(
|
|||
sessions: {type: Array, default: []}
|
||||
)
|
||||
|
||||
ScoringTaskSchema.index({createdAt: 1}, {expireAfterSeconds: 3600})
|
||||
|
||||
module.exports = mongoose.model('scoringTask', ScoringTaskSchema)
|
||||
|
|
|
@ -7,4 +7,6 @@ UserCodeProblemSchema = new mongoose.Schema({
|
|||
'default': Date.now
|
||||
}, {strict: false})
|
||||
|
||||
# TODO: add index
|
||||
|
||||
module.exports = UserCodeProblem = mongoose.model('user.code.problem', UserCodeProblemSchema)
|
||||
|
|
|
@ -19,6 +19,17 @@ UserSchema = new mongoose.Schema({
|
|||
'default': Date.now
|
||||
}, {strict: false})
|
||||
|
||||
UserSchema.index({'dateCreated': 1})
|
||||
UserSchema.index({'emailLower': 1}, {unique: true, sparse: true, name: 'emailLower_1'})
|
||||
UserSchema.index({'facebookID': 1}, {sparse: true})
|
||||
UserSchema.index({'gplusID': 1}, {sparse: true})
|
||||
UserSchema.index({'iosIdentifierForVendor': 1}, {name: 'iOS identifier for vendor', sparse: true, unique: true})
|
||||
UserSchema.index({'mailChimp.leid': 1}, {sparse: true})
|
||||
UserSchema.index({'nameLower': 1}, {sparse: true, name: 'nameLower_1'})
|
||||
UserSchema.index({'simulatedBy': 1})
|
||||
UserSchema.index({'slug': 1}, {name: 'slug index', sparse: true, unique: true})
|
||||
UserSchema.index({'stripe.subscriptionID': 1}, {unique: true, sparse: true})
|
||||
|
||||
UserSchema.post('init', ->
|
||||
@set('anonymous', false) if @get('email')
|
||||
)
|
||||
|
@ -266,9 +277,6 @@ UserSchema.statics.editableProperties = [
|
|||
]
|
||||
|
||||
UserSchema.plugin plugins.NamedPlugin
|
||||
UserSchema.index({'stripe.subscriptionID':1}, {unique: true, sparse: true})
|
||||
UserSchema.index({'emailLower':1}, {unique: true, sparse: true, name: 'emailLower_1'})
|
||||
UserSchema.index({'nameLower':1}, {unique: true, sparse: true, name: 'nameLower_1'})
|
||||
|
||||
module.exports = User = mongoose.model('User', UserSchema)
|
||||
|
||||
|
|
|
@ -8,4 +8,6 @@ UserRemarkSchema = new mongoose.Schema({
|
|||
'default': Date.now
|
||||
}, {strict: false})
|
||||
|
||||
UserRemarkSchema.index({user: 1}, {name: 'User'})
|
||||
|
||||
module.exports = UserRemark = mongoose.model('user.remark', UserRemarkSchema)
|
||||
|
|
Loading…
Reference in a new issue