PLT-92 Adding server side versioning to the binary

Этот коммит содержится в:
=Corey Hulen
2015-09-16 17:37:11 -07:00
родитель e644b53b72
Коммит cef7a1aae4
13 изменённых файлов: 199 добавлений и 23 удалений

Просмотреть файл

@@ -196,9 +196,9 @@ func (s SqlPostStore) GetEtag(channelId string) StoreChannel {
var et etagPosts
err := s.GetReplica().SelectOne(&et, "SELECT Id, UpdateAt FROM Posts WHERE ChannelId = :ChannelId ORDER BY UpdateAt DESC LIMIT 1", map[string]interface{}{"ChannelId": channelId})
if err != nil {
result.Data = fmt.Sprintf("%v.0.%v", model.ETAG_ROOT_VERSION, model.GetMillis())
result.Data = fmt.Sprintf("%v.0.%v", model.GetFullVersion(), model.GetMillis())
} else {
result.Data = fmt.Sprintf("%v.%v.%v", model.ETAG_ROOT_VERSION, et.Id, et.UpdateAt)
result.Data = fmt.Sprintf("%v.%v.%v", model.GetFullVersion(), et.Id, et.UpdateAt)
}
storeChannel <- result

Просмотреть файл

@@ -37,14 +37,14 @@ func TestPostStoreGet(t *testing.T) {
o1.Message = "a" + model.NewId() + "b"
etag1 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
if strings.Index(etag1, model.ETAG_ROOT_VERSION+".0.") != 0 {
if strings.Index(etag1, model.GetFullVersion()+".0.") != 0 {
t.Fatal("Invalid Etag")
}
o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
etag2 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
if strings.Index(etag2, model.ETAG_ROOT_VERSION+"."+o1.Id) != 0 {
if strings.Index(etag2, model.GetFullVersion()+"."+o1.Id) != 0 {
t.Fatal("Invalid Etag")
}
@@ -136,7 +136,7 @@ func TestPostStoreDelete(t *testing.T) {
o1.Message = "a" + model.NewId() + "b"
etag1 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
if strings.Index(etag1, model.ETAG_ROOT_VERSION+".0.") != 0 {
if strings.Index(etag1, model.GetFullVersion()+".0.") != 0 {
t.Fatal("Invalid Etag")
}
@@ -160,7 +160,7 @@ func TestPostStoreDelete(t *testing.T) {
}
etag2 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
if strings.Index(etag2, model.ETAG_ROOT_VERSION+"."+o1.Id) != 0 {
if strings.Index(etag2, model.GetFullVersion()+"."+o1.Id) != 0 {
t.Fatal("Invalid Etag")
}
}

Просмотреть файл

@@ -56,6 +56,8 @@ func NewSqlStore() Store {
utils.Cfg.SqlSettings.Trace)
}
//version := sqlStore.GetCurrentSchemaVersion()
// Temporary upgrade code, remove after 0.8.0 release
if sqlStore.DoesColumnExist("Sessions", "AltId") {
sqlStore.GetMaster().Exec("DROP TABLE IF EXISTS Sessions")
@@ -131,6 +133,11 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle
return dbmap
}
func (ss SqlStore) GetCurrentSchemaVersion() string {
version, _ := ss.GetMaster().SelectStr("SELECT PropVal FROM MattermostSystem WHERE PropName='SchemaVersion'")
return version
}
func (ss SqlStore) DoesColumnExist(tableName string, columnName string) bool {
if utils.Cfg.SqlSettings.DriverName == "postgres" {
count, err := ss.GetMaster().SelectInt(

Просмотреть файл

@@ -325,9 +325,9 @@ func (s SqlUserStore) GetEtagForProfiles(teamId string) StoreChannel {
updateAt, err := s.GetReplica().SelectInt("SELECT UpdateAt FROM Users WHERE TeamId = :TeamId ORDER BY UpdateAt DESC LIMIT 1", map[string]interface{}{"TeamId": teamId})
if err != nil {
result.Data = fmt.Sprintf("%v.%v", model.ETAG_ROOT_VERSION, model.GetMillis())
result.Data = fmt.Sprintf("%v.%v", model.GetFullVersion(), model.GetMillis())
} else {
result.Data = fmt.Sprintf("%v.%v", model.ETAG_ROOT_VERSION, updateAt)
result.Data = fmt.Sprintf("%v.%v", model.GetFullVersion(), updateAt)
}
storeChannel <- result