Removing old DB upgrade code
Этот коммит содержится в:
@@ -40,55 +40,6 @@ func NewSqlChannelStore(sqlStore *SqlStore) ChannelStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) UpgradeSchemaIfNeeded() {
|
func (s SqlChannelStore) UpgradeSchemaIfNeeded() {
|
||||||
|
|
||||||
// REMOVE AFTER 1.2 SHIP see PLT-828
|
|
||||||
if s.CreateColumnIfNotExists("ChannelMembers", "NotifyProps", "varchar(2000)", "varchar(2000)", "{}") {
|
|
||||||
// populate NotifyProps from existing NotifyLevel field
|
|
||||||
|
|
||||||
// set default values
|
|
||||||
_, err := s.GetMaster().Exec(
|
|
||||||
`UPDATE
|
|
||||||
ChannelMembers
|
|
||||||
SET
|
|
||||||
NotifyProps = CONCAT('{"desktop":"', CONCAT(NotifyLevel, '","mark_unread":"` + model.CHANNEL_MARK_UNREAD_ALL + `"}'))`)
|
|
||||||
if err != nil {
|
|
||||||
l4g.Error("Unable to set default values for ChannelMembers.NotifyProps")
|
|
||||||
l4g.Error(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// assume channels with all notifications enabled are just using the default settings
|
|
||||||
_, err = s.GetMaster().Exec(
|
|
||||||
`UPDATE
|
|
||||||
ChannelMembers
|
|
||||||
SET
|
|
||||||
NotifyProps = '{"desktop":"` + model.CHANNEL_NOTIFY_DEFAULT + `","mark_unread":"` + model.CHANNEL_MARK_UNREAD_ALL + `"}'
|
|
||||||
WHERE
|
|
||||||
NotifyLevel = '` + model.CHANNEL_NOTIFY_ALL + `'`)
|
|
||||||
if err != nil {
|
|
||||||
l4g.Error("Unable to set values for ChannelMembers.NotifyProps when members previously had notifyLevel=all")
|
|
||||||
l4g.Error(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// set quiet mode channels to have no notifications and only mark the channel unread on mentions
|
|
||||||
_, err = s.GetMaster().Exec(
|
|
||||||
`UPDATE
|
|
||||||
ChannelMembers
|
|
||||||
SET
|
|
||||||
NotifyProps = '{"desktop":"` + model.CHANNEL_NOTIFY_NONE + `","mark_unread":"` + model.CHANNEL_MARK_UNREAD_MENTION + `"}'
|
|
||||||
WHERE
|
|
||||||
NotifyLevel = 'quiet'`)
|
|
||||||
if err != nil {
|
|
||||||
l4g.Error("Unable to set values for ChannelMembers.NotifyProps when members previously had notifyLevel=quiet")
|
|
||||||
l4g.Error(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
func (s SqlChannelStore) CreateIndexesIfNotExists() {
|
||||||
|
|||||||
@@ -9,10 +9,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
l4g "code.google.com/p/log4go"
|
|
||||||
"github.com/mattermost/platform/model"
|
"github.com/mattermost/platform/model"
|
||||||
"github.com/mattermost/platform/utils"
|
"github.com/mattermost/platform/utils"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SqlPostStore struct {
|
type SqlPostStore struct {
|
||||||
@@ -40,21 +38,6 @@ func NewSqlPostStore(sqlStore *SqlStore) PostStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlPostStore) UpgradeSchemaIfNeeded() {
|
func (s SqlPostStore) UpgradeSchemaIfNeeded() {
|
||||||
colType := s.GetColumnDataType("Posts", "Props")
|
|
||||||
if colType != "text" {
|
|
||||||
|
|
||||||
query := "ALTER TABLE Posts MODIFY COLUMN Props TEXT"
|
|
||||||
if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
|
|
||||||
query = "ALTER TABLE Posts ALTER COLUMN Props TYPE text"
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := s.GetMaster().Exec(query)
|
|
||||||
if err != nil {
|
|
||||||
l4g.Critical("Failed to alter column Posts.Props to TEXT: " + err.Error())
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
panic("Failed to alter column Posts.Props to TEXT: " + err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlPostStore) CreateIndexesIfNotExists() {
|
func (s SqlPostStore) CreateIndexesIfNotExists() {
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ func NewSqlTeamStore(sqlStore *SqlStore) TeamStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlTeamStore) UpgradeSchemaIfNeeded() {
|
func (s SqlTeamStore) UpgradeSchemaIfNeeded() {
|
||||||
// REMOVE AFTER 1.2 SHIP see PLT-828
|
|
||||||
s.RemoveColumnIfExists("Teams", "AllowValet")
|
|
||||||
s.CreateColumnIfNotExists("Teams", "InviteId", "varchar(32)", "varchar(32)", "")
|
|
||||||
s.CreateColumnIfNotExists("Teams", "AllowOpenInvite", "tinyint(1)", "boolean", "0")
|
|
||||||
s.CreateColumnIfNotExists("Teams", "AllowTeamListing", "tinyint(1)", "boolean", "0")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlTeamStore) CreateIndexesIfNotExists() {
|
func (s SqlTeamStore) CreateIndexesIfNotExists() {
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ func NewSqlUserStore(sqlStore *SqlStore) UserStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (us SqlUserStore) UpgradeSchemaIfNeeded() {
|
func (us SqlUserStore) UpgradeSchemaIfNeeded() {
|
||||||
// REMOVE AFTER 1.2 SHIP see PLT-828
|
|
||||||
us.CreateColumnIfNotExists("Users", "ThemeProps", "varchar(2000)", "character varying(2000)", "{}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (us SqlUserStore) CreateIndexesIfNotExists() {
|
func (us SqlUserStore) CreateIndexesIfNotExists() {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user