Combine alterations on Posts table (#18210)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ab0e82d656
Коммит
74518ea165
@@ -1301,10 +1301,21 @@ func fixCRTChannelMembershipCounts(sqlStore *SqlStore) {
|
|||||||
func upgradeDatabaseToVersion600(sqlStore *SqlStore) {
|
func upgradeDatabaseToVersion600(sqlStore *SqlStore) {
|
||||||
// if shouldPerformUpgrade(sqlStore, Version5380, Version600) {
|
// if shouldPerformUpgrade(sqlStore, Version5380, Version600) {
|
||||||
|
|
||||||
|
if sqlStore.DriverName() == model.DatabaseDriverMysql {
|
||||||
|
if sqlStore.DoesColumnExist("Posts", "ParentId") {
|
||||||
|
sqlStore.GetMaster().ExecNoTimeout("ALTER TABLE Posts MODIFY COLUMN FileIds text, MODIFY COLUMN Props JSON, DROP COLUMN ParentId")
|
||||||
|
} else {
|
||||||
|
sqlStore.GetMaster().ExecNoTimeout("ALTER TABLE Posts MODIFY COLUMN FileIds text, MODIFY COLUMN Props JSON")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sqlStore.AlterColumnTypeIfExists("ChannelMembers", "NotifyProps", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("ChannelMembers", "NotifyProps", "JSON", "jsonb")
|
||||||
sqlStore.AlterColumnTypeIfExists("Jobs", "Data", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("Jobs", "Data", "JSON", "jsonb")
|
||||||
sqlStore.AlterColumnTypeIfExists("LinkMetadata", "Data", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("LinkMetadata", "Data", "JSON", "jsonb")
|
||||||
sqlStore.AlterColumnTypeIfExists("Posts", "Props", "JSON", "jsonb")
|
|
||||||
|
if sqlStore.DriverName() == model.DatabaseDriverPostgres {
|
||||||
|
sqlStore.AlterColumnTypeIfExists("Posts", "Props", "JSON", "jsonb")
|
||||||
|
}
|
||||||
sqlStore.AlterColumnTypeIfExists("Sessions", "Props", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("Sessions", "Props", "JSON", "jsonb")
|
||||||
sqlStore.AlterColumnTypeIfExists("Threads", "Participants", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("Threads", "Participants", "JSON", "jsonb")
|
||||||
sqlStore.AlterColumnTypeIfExists("Users", "Props", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("Users", "Props", "JSON", "jsonb")
|
||||||
@@ -1312,12 +1323,15 @@ func upgradeDatabaseToVersion600(sqlStore *SqlStore) {
|
|||||||
sqlStore.AlterColumnTypeIfExists("Users", "Timezone", "JSON", "jsonb")
|
sqlStore.AlterColumnTypeIfExists("Users", "Timezone", "JSON", "jsonb")
|
||||||
|
|
||||||
sqlStore.GetMaster().ExecNoTimeout("UPDATE Posts SET RootId = ParentId WHERE RootId = '' AND RootId != ParentId")
|
sqlStore.GetMaster().ExecNoTimeout("UPDATE Posts SET RootId = ParentId WHERE RootId = '' AND RootId != ParentId")
|
||||||
sqlStore.RemoveColumnIfExists("Posts", "ParentId")
|
if sqlStore.DriverName() == model.DatabaseDriverPostgres {
|
||||||
|
sqlStore.RemoveColumnIfExists("Posts", "ParentId")
|
||||||
|
}
|
||||||
sqlStore.GetMaster().ExecNoTimeout("UPDATE CommandWebhooks SET RootId = ParentId WHERE RootId = '' AND RootId != ParentId")
|
sqlStore.GetMaster().ExecNoTimeout("UPDATE CommandWebhooks SET RootId = ParentId WHERE RootId = '' AND RootId != ParentId")
|
||||||
sqlStore.RemoveColumnIfExists("CommandWebhooks", "ParentId")
|
sqlStore.RemoveColumnIfExists("CommandWebhooks", "ParentId")
|
||||||
|
|
||||||
// allow 10 files per post
|
if sqlStore.DriverName() == model.DatabaseDriverPostgres {
|
||||||
sqlStore.AlterColumnTypeIfExists("Posts", "FileIds", "text", "varchar(300)")
|
sqlStore.AlterColumnTypeIfExists("Posts", "FileIds", "text", "varchar(300)")
|
||||||
|
}
|
||||||
|
|
||||||
// saveSchemaVersion(sqlStore, Version600)
|
// saveSchemaVersion(sqlStore, Version600)
|
||||||
// }
|
// }
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user