/
v11.go
86 lines (77 loc) · 1.66 KB
/
v11.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package postgres
import (
"database/sql"
"log"
)
func (c *Controller) V11(db *sql.Tx) {
v11ExtendAccountAndDescriptionHintsInSuggestions(db)
v11ExtendAccountHintsInExistingTemplates(db)
v11RemoveUserSettingTypesLimits(db)
}
func v11ExtendAccountAndDescriptionHintsInSuggestions(db *sql.Tx) {
sqlStatement := `
UPDATE "bot::cache"
SET "type" = 'account:from'
WHERE "type" = 'accFrom';
`
_, err := db.Exec(sqlStatement)
if err != nil {
log.Fatal(err)
}
sqlStatement = `
UPDATE "bot::cache"
SET "type" = 'account:to'
WHERE "type" = 'accTo';
`
_, err = db.Exec(sqlStatement)
if err != nil {
log.Fatal(err)
}
sqlStatement = `
UPDATE "bot::cache"
SET "type" = 'description:'
WHERE "type" = 'txDesc';
`
_, err = db.Exec(sqlStatement)
if err != nil {
log.Fatal(err)
}
}
func v11ExtendAccountHintsInExistingTemplates(db *sql.Tx) {
sqlStatement := `
UPDATE "bot::template"
SET "template" = REPLACE("template", '${from}', '${account:from}')
WHERE "template" LIKE '%${from}%';
`
_, err := db.Exec(sqlStatement)
if err != nil {
log.Fatal(err)
}
sqlStatement = `
UPDATE "bot::template"
SET "template" = REPLACE("template", '${to}', '${account:to}')
WHERE "template" LIKE '%${to}%';
`
_, err = db.Exec(sqlStatement)
if err != nil {
log.Fatal(err)
}
}
func v11RemoveUserSettingTypesLimits(db *sql.Tx) {
sqlStatement := `
DELETE FROM "bot::userSetting"
WHERE "setting" LIKE 'user.limitCache.%';
`
_, err := db.Exec(sqlStatement)
if err != nil {
log.Fatal(err)
}
sqlStatement = `
DELETE FROM "bot::userSettingTypes"
WHERE "setting" LIKE 'user.limitCache.%';
`
_, err = db.Exec(sqlStatement)
if err != nil {
log.Fatal(err)
}
}