-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
49_create_elastic_index_presence_updates.go
60 lines (54 loc) · 1.28 KB
/
49_create_elastic_index_presence_updates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package migrations
import (
"context"
"github.com/Seklfreak/Robyul2/cache"
)
func m49_create_elastic_index_presence_updates() {
if !cache.HasElastic() {
return
}
elastic := cache.GetElastic()
exists, err := elastic.IndexExists("robyul-presence_updates").Do(context.Background())
if err != nil {
panic(err)
}
if exists {
return
}
presenceUpdateMapping := map[string]interface{}{
"mappings": map[string]interface{}{
"doc": map[string]interface{}{
"properties": map[string]interface{}{
"CreatedAt": map[string]interface{}{
"type": "date",
},
"UserID": map[string]interface{}{
"type": "text",
},
"GameType": map[string]interface{}{
"type": "long",
},
"GameTypeV2": map[string]interface{}{
"type": "text",
},
"GameName": map[string]interface{}{
"type": "text",
},
"GameURL": map[string]interface{}{
"type": "text",
},
"Status": map[string]interface{}{
"type": "text",
},
},
},
},
}
index, err := elastic.CreateIndex("robyul-presence_updates").BodyJson(presenceUpdateMapping).Do(context.Background())
if err != nil {
panic(err)
}
if !index.Acknowledged {
cache.GetLogger().WithField("module", "migrations").Error("ElasticSearch index not acknowledged")
}
}