summaryrefslogtreecommitdiffstats
path: root/store/sql_store.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-10-01 14:07:20 -0400
committerJoramWilander <jwawilander@gmail.com>2015-10-19 09:00:30 -0400
commitaf6e2c29eb0a8610fe218e8ec85e739433eac729 (patch)
tree59836ace0d50cc62b99f007916212454bd5c9e99 /store/sql_store.go
parente308923aeca0a45463aeeeea7b0b3e3bc313f033 (diff)
downloadchat-af6e2c29eb0a8610fe218e8ec85e739433eac729.tar.gz
chat-af6e2c29eb0a8610fe218e8ec85e739433eac729.tar.bz2
chat-af6e2c29eb0a8610fe218e8ec85e739433eac729.zip
Implement outgoing webhooks.
Diffstat (limited to 'store/sql_store.go')
-rw-r--r--store/sql_store.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/store/sql_store.go b/store/sql_store.go
index 692ac2664..a1a542691 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -30,6 +30,12 @@ import (
"github.com/mattermost/platform/utils"
)
+const (
+ INDEX_TYPE_FULL_TEXT = "full_text"
+ INDEX_TYPE_PATTERN = "pattern"
+ INDEX_TYPE_DEFAULT = "default"
+)
+
type SqlStore struct {
master *gorp.DbMap
replicas []*gorp.DbMap
@@ -363,14 +369,18 @@ func (ss SqlStore) RemoveColumnIfExists(tableName string, columnName string) boo
// }
func (ss SqlStore) CreateIndexIfNotExists(indexName string, tableName string, columnName string) {
- ss.createIndexIfNotExists(indexName, tableName, columnName, false)
+ ss.createIndexIfNotExists(indexName, tableName, columnName, INDEX_TYPE_DEFAULT)
}
func (ss SqlStore) CreateFullTextIndexIfNotExists(indexName string, tableName string, columnName string) {
- ss.createIndexIfNotExists(indexName, tableName, columnName, true)
+ ss.createIndexIfNotExists(indexName, tableName, columnName, INDEX_TYPE_FULL_TEXT)
+}
+
+func (ss SqlStore) CreatePatternIndexIfNotExists(indexName string, tableName string, columnName string) {
+ ss.createIndexIfNotExists(indexName, tableName, columnName, INDEX_TYPE_PATTERN)
}
-func (ss SqlStore) createIndexIfNotExists(indexName string, tableName string, columnName string, fullText bool) {
+func (ss SqlStore) createIndexIfNotExists(indexName string, tableName string, columnName string, indexType string) {
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
_, err := ss.GetMaster().SelectStr("SELECT $1::regclass", indexName)
@@ -380,8 +390,10 @@ func (ss SqlStore) createIndexIfNotExists(indexName string, tableName string, co
}
query := ""
- if fullText {
+ if indexType == INDEX_TYPE_FULL_TEXT {
query = "CREATE INDEX " + indexName + " ON " + tableName + " USING gin(to_tsvector('english', " + columnName + "))"
+ } else if indexType == INDEX_TYPE_PATTERN {
+ query = "CREATE INDEX " + indexName + " ON " + tableName + " (" + columnName + " text_pattern_ops)"
} else {
query = "CREATE INDEX " + indexName + " ON " + tableName + " (" + columnName + ")"
}
@@ -406,7 +418,7 @@ func (ss SqlStore) createIndexIfNotExists(indexName string, tableName string, co
}
fullTextIndex := ""
- if fullText {
+ if indexType == INDEX_TYPE_FULL_TEXT || indexType == INDEX_TYPE_PATTERN {
fullTextIndex = " FULLTEXT "
}