Drop existing default on Users.Timezone prior to column type change (#18669)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
850fef1ad1
Коммит
9d8214c72a
@@ -133,6 +133,7 @@ type SqlStore struct {
|
||||
// ColumnInfo holds information about a column.
|
||||
type ColumnInfo struct {
|
||||
DataType string
|
||||
DefaultValue string
|
||||
CharMaximumLength int
|
||||
}
|
||||
|
||||
@@ -651,7 +652,7 @@ func (ss *SqlStore) GetColumnInfo(tableName, columnName string) (*ColumnInfo, er
|
||||
var columnInfo ColumnInfo
|
||||
if ss.DriverName() == model.DatabaseDriverPostgres {
|
||||
err := ss.GetMaster().SelectOne(&columnInfo,
|
||||
`SELECT data_type as DataType,
|
||||
`SELECT data_type as DataType, COALESCE(column_default, '') as DefaultValue,
|
||||
COALESCE(character_maximum_length, 0) as CharMaximumLength
|
||||
FROM information_schema.columns
|
||||
WHERE lower(table_name) = lower($1)
|
||||
@@ -663,7 +664,7 @@ func (ss *SqlStore) GetColumnInfo(tableName, columnName string) (*ColumnInfo, er
|
||||
return &columnInfo, nil
|
||||
} else if ss.DriverName() == model.DatabaseDriverMysql {
|
||||
err := ss.GetMaster().SelectOne(&columnInfo,
|
||||
`SELECT data_type as DataType,
|
||||
`SELECT data_type as DataType, COALESCE(column_default, '') as DefaultValue,
|
||||
COALESCE(character_maximum_length, 0) as CharMaximumLength
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
|
||||
@@ -1301,7 +1301,6 @@ func upgradeDatabaseToVersion539(sqlStore *SqlStore) {
|
||||
|
||||
func upgradeDatabaseToVersion600(sqlStore *SqlStore) {
|
||||
if shouldPerformUpgrade(sqlStore, Version5390, Version600) {
|
||||
|
||||
sqlStore.GetMaster().ExecNoTimeout("UPDATE Posts SET RootId = ParentId WHERE RootId = '' AND RootId != ParentId")
|
||||
if sqlStore.DriverName() == model.DatabaseDriverMysql {
|
||||
if sqlStore.DoesColumnExist("Posts", "ParentId") {
|
||||
@@ -1323,6 +1322,16 @@ func upgradeDatabaseToVersion600(sqlStore *SqlStore) {
|
||||
sqlStore.AlterColumnTypeIfExists("Threads", "Participants", "JSON", "jsonb")
|
||||
sqlStore.AlterColumnTypeIfExists("Users", "Props", "JSON", "jsonb")
|
||||
sqlStore.AlterColumnTypeIfExists("Users", "NotifyProps", "JSON", "jsonb")
|
||||
info, err := sqlStore.GetColumnInfo("Users", "Timezone")
|
||||
if err != nil {
|
||||
mlog.Error("Error getting column info",
|
||||
mlog.String("table", "Users"),
|
||||
mlog.String("column", "Timezone"),
|
||||
mlog.Err(err),
|
||||
)
|
||||
} else if info.DefaultValue != "" {
|
||||
sqlStore.RemoveDefaultIfColumnExists("Users", "Timezone")
|
||||
}
|
||||
sqlStore.AlterColumnTypeIfExists("Users", "Timezone", "JSON", "jsonb")
|
||||
|
||||
sqlStore.GetMaster().ExecNoTimeout("UPDATE CommandWebhooks SET RootId = ParentId WHERE RootId = '' AND RootId != ParentId")
|
||||
|
||||
Ссылка в новой задаче
Block a user