summaryrefslogtreecommitdiffstats
path: root/store/sql_store.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-10-28 14:44:02 -0700
committerCorey Hulen <corey@hulen.com>2015-10-28 14:44:02 -0700
commit89f67cd11dbb71d42a8809976715d6df86d46c95 (patch)
tree3e3c50d16a6dea22f5270ab61255c975e3eb6147 /store/sql_store.go
parent9312272234c9bb41741ac174fb4b19c73426dce0 (diff)
parent019bf6a7fed85138a6a3be6ef70fbb994be49abe (diff)
downloadchat-89f67cd11dbb71d42a8809976715d6df86d46c95.tar.gz
chat-89f67cd11dbb71d42a8809976715d6df86d46c95.tar.bz2
chat-89f67cd11dbb71d42a8809976715d6df86d46c95.zip
Merge pull request #1199 from hmhealey/plt600
PLT-600 Renamed channel description to channel header and added channel purpose field
Diffstat (limited to 'store/sql_store.go')
-rw-r--r--store/sql_store.go35
1 files changed, 17 insertions, 18 deletions
diff --git a/store/sql_store.go b/store/sql_store.go
index d5c84d522..8965fef64 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -364,27 +364,26 @@ func (ss SqlStore) RemoveColumnIfExists(tableName string, columnName string) boo
return true
}
-// func (ss SqlStore) RenameColumnIfExists(tableName string, oldColumnName string, newColumnName string, colType string) bool {
-
-// // XXX TODO FIXME this should be removed after 0.6.0
-// if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
-// return false
-// }
-
-// if !ss.DoesColumnExist(tableName, oldColumnName) {
-// return false
-// }
+func (ss SqlStore) RenameColumnIfExists(tableName string, oldColumnName string, newColumnName string, colType string) bool {
+ if !ss.DoesColumnExist(tableName, oldColumnName) {
+ return false
+ }
-// _, err := ss.GetMaster().Exec("ALTER TABLE " + tableName + " CHANGE " + oldColumnName + " " + newColumnName + " " + colType)
+ var err error
+ if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
+ _, err = ss.GetMaster().Exec("ALTER TABLE " + tableName + " CHANGE " + oldColumnName + " " + newColumnName + " " + colType)
+ } else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
+ _, err = ss.GetMaster().Exec("ALTER TABLE " + tableName + " RENAME COLUMN " + oldColumnName + " TO " + newColumnName)
+ }
-// if err != nil {
-// l4g.Critical("Failed to rename column %v", err)
-// time.Sleep(time.Second)
-// panic("Failed to drop column " + err.Error())
-// }
+ if err != nil {
+ l4g.Critical("Failed to rename column %v", err)
+ time.Sleep(time.Second)
+ panic("Failed to drop column " + err.Error())
+ }
-// return true
-// }
+ return true
+}
func (ss SqlStore) CreateIndexIfNotExists(indexName string, tableName string, columnName string) {
ss.createIndexIfNotExists(indexName, tableName, columnName, INDEX_TYPE_DEFAULT)