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.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/store/sql_store.go b/store/sql_store.go
index 4ec954042..543945605 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -25,6 +25,7 @@ import (
sqltrace "log"
"math/rand"
"os"
+ "strings"
"time"
)
@@ -123,10 +124,6 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle
func (ss SqlStore) CreateColumnIfNotExists(tableName string, columnName string, colType string, defaultValue string) bool {
- // SELECT column_name
- // FROM information_schema.columns
- // WHERE table_name='your_table' and column_name='your_column';
-
var count int64
var err error
@@ -272,6 +269,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
}