Address outstanding merging issues with cloud branch (#17160)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c5e1b36dd3
Коммит
d3a003dcb2
@@ -45,7 +45,7 @@ const (
|
|||||||
POST_EPHEMERAL = "system_ephemeral"
|
POST_EPHEMERAL = "system_ephemeral"
|
||||||
POST_CHANGE_CHANNEL_PRIVACY = "system_change_chan_privacy"
|
POST_CHANGE_CHANNEL_PRIVACY = "system_change_chan_privacy"
|
||||||
POST_ADD_BOT_TEAMS_CHANNELS = "add_bot_teams_channels"
|
POST_ADD_BOT_TEAMS_CHANNELS = "add_bot_teams_channels"
|
||||||
POST_FILEIDS_MAX_RUNES = 150
|
POST_FILEIDS_MAX_RUNES = 300
|
||||||
POST_FILENAMES_MAX_RUNES = 4000
|
POST_FILENAMES_MAX_RUNES = 4000
|
||||||
POST_HASHTAGS_MAX_RUNES = 1000
|
POST_HASHTAGS_MAX_RUNES = 1000
|
||||||
POST_MESSAGE_MAX_RUNES_V1 = 4000
|
POST_MESSAGE_MAX_RUNES_V1 = 4000
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ CREATE TABLE `Posts` (
|
|||||||
`Props` text,
|
`Props` text,
|
||||||
`Hashtags` text,
|
`Hashtags` text,
|
||||||
`Filenames` text,
|
`Filenames` text,
|
||||||
`FileIds` varchar(150) DEFAULT NULL,
|
`FileIds` text,
|
||||||
`HasReactions` tinyint(1) DEFAULT NULL,
|
`HasReactions` tinyint(1) DEFAULT NULL,
|
||||||
PRIMARY KEY (`Id`),
|
PRIMARY KEY (`Id`),
|
||||||
KEY `idx_posts_update_at` (`UpdateAt`),
|
KEY `idx_posts_update_at` (`UpdateAt`),
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ CREATE TABLE public.posts (
|
|||||||
props character varying(8000),
|
props character varying(8000),
|
||||||
hashtags character varying(1000),
|
hashtags character varying(1000),
|
||||||
filenames character varying(4000),
|
filenames character varying(4000),
|
||||||
fileids character varying(150),
|
fileids character varying(300),
|
||||||
hasreactions boolean
|
hasreactions boolean
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ func newSqlPostStore(sqlStore *SqlStore, metrics einterfaces.MetricsInterface) s
|
|||||||
table.ColMap("Hashtags").SetMaxSize(1000)
|
table.ColMap("Hashtags").SetMaxSize(1000)
|
||||||
table.ColMap("Props").SetMaxSize(8000)
|
table.ColMap("Props").SetMaxSize(8000)
|
||||||
table.ColMap("Filenames").SetMaxSize(model.POST_FILENAMES_MAX_RUNES)
|
table.ColMap("Filenames").SetMaxSize(model.POST_FILENAMES_MAX_RUNES)
|
||||||
table.ColMap("FileIds").SetMaxSize(150)
|
table.ColMap("FileIds").SetMaxSize(300)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|||||||
@@ -145,6 +145,12 @@ type SqlStore struct {
|
|||||||
|
|
||||||
type TraceOnAdapter struct{}
|
type TraceOnAdapter struct{}
|
||||||
|
|
||||||
|
// ColumnInfo holds information about a column.
|
||||||
|
type ColumnInfo struct {
|
||||||
|
DataType string
|
||||||
|
CharMaximumLength int
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TraceOnAdapter) Printf(format string, v ...interface{}) {
|
func (t *TraceOnAdapter) Printf(format string, v ...interface{}) {
|
||||||
originalString := fmt.Sprintf(format, v...)
|
originalString := fmt.Sprintf(format, v...)
|
||||||
newString := strings.ReplaceAll(originalString, "\n", " ")
|
newString := strings.ReplaceAll(originalString, "\n", " ")
|
||||||
@@ -543,6 +549,52 @@ func (ss *SqlStore) DoesColumnExist(tableName string, columnName string) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetColumnInfo returns data type information about the given column.
|
||||||
|
func (ss *SqlStore) GetColumnInfo(tableName, columnName string) (*ColumnInfo, error) {
|
||||||
|
var columnInfo ColumnInfo
|
||||||
|
if ss.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||||
|
err := ss.GetMaster().SelectOne(&columnInfo,
|
||||||
|
`SELECT data_type as DataType,
|
||||||
|
COALESCE(character_maximum_length, 0) as CharMaximumLength
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE lower(table_name) = lower($1)
|
||||||
|
AND lower(column_name) = lower($2)`,
|
||||||
|
tableName, columnName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &columnInfo, nil
|
||||||
|
} else if ss.DriverName() == model.DATABASE_DRIVER_MYSQL {
|
||||||
|
err := ss.GetMaster().SelectOne(&columnInfo,
|
||||||
|
`SELECT data_type as DataType,
|
||||||
|
COALESCE(character_maximum_length, 0) as CharMaximumLength
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND lower(table_name) = lower(?)
|
||||||
|
AND lower(column_name) = lower(?)`,
|
||||||
|
tableName, columnName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &columnInfo, nil
|
||||||
|
}
|
||||||
|
return nil, errors.New("Driver not supported for this method")
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsVarchar returns true if the column type matches one of the varchar types
|
||||||
|
// either in MySQL or PostgreSQL.
|
||||||
|
func (ss *SqlStore) IsVarchar(columnType string) bool {
|
||||||
|
if ss.DriverName() == model.DATABASE_DRIVER_POSTGRES && columnType == "character varying" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if ss.DriverName() == model.DATABASE_DRIVER_MYSQL && columnType == "varchar" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
|
func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
|
||||||
if ss.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
if ss.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||||
count, err := ss.GetMaster().SelectInt(`
|
count, err := ss.GetMaster().SelectInt(`
|
||||||
|
|||||||
@@ -959,7 +959,30 @@ func upgradeDatabaseToVersion531(sqlStore *SqlStore) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hasMissingMigrationsVersion532(sqlStore *SqlStore) bool {
|
||||||
|
scIdInfo, err := sqlStore.GetColumnInfo("Posts", "FileIds")
|
||||||
|
if err != nil {
|
||||||
|
mlog.Error("Error getting column info for migration check",
|
||||||
|
mlog.String("table", "Posts"),
|
||||||
|
mlog.String("column", "FileIds"),
|
||||||
|
mlog.Err(err),
|
||||||
|
)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if sqlStore.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||||
|
if !sqlStore.IsVarchar(scIdInfo.DataType) || scIdInfo.CharMaximumLength != 300 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func upgradeDatabaseToVersion532(sqlStore *SqlStore) {
|
func upgradeDatabaseToVersion532(sqlStore *SqlStore) {
|
||||||
|
if sqlStore.DriverName() == model.DATABASE_DRIVER_POSTGRES && hasMissingMigrationsVersion532(sqlStore) {
|
||||||
|
sqlStore.AlterColumnTypeIfExists("Posts", "FileIds", "text", "varchar(300)")
|
||||||
|
}
|
||||||
if shouldPerformUpgrade(sqlStore, Version5310, Version5320) {
|
if shouldPerformUpgrade(sqlStore, Version5310, Version5320) {
|
||||||
sqlStore.CreateColumnIfNotExists("ThreadMemberships", "UnreadMentions", "bigint", "bigint", "0")
|
sqlStore.CreateColumnIfNotExists("ThreadMemberships", "UnreadMentions", "bigint", "bigint", "0")
|
||||||
sqlStore.CreateColumnIfNotExistsNoDefault("Channels", "Shared", "tinyint(1)", "boolean")
|
sqlStore.CreateColumnIfNotExistsNoDefault("Channels", "Shared", "tinyint(1)", "boolean")
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user