summaryrefslogtreecommitdiffstats
path: root/store/sql_store.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/sql_store.go')
-rw-r--r--store/sql_store.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/store/sql_store.go b/store/sql_store.go
index 2e4981e6b..216060dba 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -18,6 +18,7 @@ import (
"fmt"
"github.com/go-gorp/gorp"
_ "github.com/go-sql-driver/mysql"
+ _ "github.com/lib/pq"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
"io"
@@ -113,6 +114,8 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle
dbmap = &gorp.DbMap{Db: db, TypeConverter: mattermConverter{}, Dialect: gorp.SqliteDialect{}}
} else if driver == "mysql" {
dbmap = &gorp.DbMap{Db: db, TypeConverter: mattermConverter{}, Dialect: gorp.MySQLDialect{Engine: "InnoDB", Encoding: "UTF8MB4"}}
+ } else if driver == "postgres" {
+ dbmap = &gorp.DbMap{Db: db, TypeConverter: mattermConverter{}, Dialect: gorp.PostgresDialect{}}
} else {
l4g.Critical("Failed to create dialect specific driver")
time.Sleep(time.Second)
@@ -230,6 +233,12 @@ func (ss SqlStore) createIndexIfNotExists(indexName string, tableName string, co
}
}
+func IsUniqueConstraintError(err string, mysql string, postgres string) bool {
+ unique := strings.Contains(err, "unique constraint") || strings.Contains(err, "Duplicate entry")
+ field := strings.Contains(err, mysql) || strings.Contains(err, postgres)
+ return unique && field
+}
+
func (ss SqlStore) GetMaster() *gorp.DbMap {
return ss.master
}