summaryrefslogtreecommitdiffstats
path: root/store
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
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')
-rw-r--r--store/sql_channel_store.go8
-rw-r--r--store/sql_store.go35
2 files changed, 24 insertions, 19 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 80fe75130..14896c0a0 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -25,7 +25,8 @@ func NewSqlChannelStore(sqlStore *SqlStore) ChannelStore {
table.ColMap("DisplayName").SetMaxSize(64)
table.ColMap("Name").SetMaxSize(64)
table.SetUniqueTogether("Name", "TeamId")
- table.ColMap("Description").SetMaxSize(1024)
+ table.ColMap("Header").SetMaxSize(1024)
+ table.ColMap("Purpose").SetMaxSize(128)
table.ColMap("CreatorId").SetMaxSize(26)
tablem := db.AddTableWithName(model.ChannelMember{}, "ChannelMembers").SetKeys(false, "ChannelId", "UserId")
@@ -83,6 +84,11 @@ func (s SqlChannelStore) UpgradeSchemaIfNeeded() {
s.RemoveColumnIfExists("ChannelMembers", "NotifyLevel")
}
+
+ // BEGIN REMOVE AFTER 1.2.0
+ s.RenameColumnIfExists("Channels", "Description", "Header", "varchar(1024)")
+ s.CreateColumnIfNotExists("Channels", "Purpose", "varchar(1024)", "varchar(1024)", "")
+ // END REMOVE AFTER 1.2.0
}
func (s SqlChannelStore) CreateIndexesIfNotExists() {
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)