mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-34792 test shouldn't depend on upgrade sequence (#17425)
This commit is contained in:
@@ -1032,10 +1032,16 @@ func upgradeDatabaseToVersion535(sqlStore *SqlStore) {
|
||||
sqlStore.CreateUniqueCompositeIndexIfNotExists(RemoteClusterSiteURLUniqueIndex, "RemoteClusters", uniquenessColumns)
|
||||
sqlStore.CreateColumnIfNotExists("SharedChannelUsers", "ChannelId", "VARCHAR(26)", "VARCHAR(26)", "")
|
||||
|
||||
rootCountMigration(sqlStore)
|
||||
|
||||
// saveSchemaVersion(sqlStore, Version5350)
|
||||
// }
|
||||
}
|
||||
|
||||
func rootCountMigration(sqlStore *SqlStore) {
|
||||
totalMsgCountRootExists := sqlStore.DoesColumnExist("Channels", "TotalMsgCountRoot")
|
||||
msgCountRootExists := sqlStore.DoesColumnExist("ChannelMembers", "MsgCountRoot")
|
||||
|
||||
// note: setting default 0 on pre-5.0 tables causes test-db-migration script to fail, so this column will be added to ignore list
|
||||
sqlStore.CreateColumnIfNotExists("ChannelMembers", "MentionCountRoot", "bigint", "bigint", "0")
|
||||
sqlStore.AlterColumnDefaultIfExists("ChannelMembers", "MentionCountRoot", model.NewString("0"), model.NewString("0"))
|
||||
|
||||
@@ -1071,7 +1077,6 @@ func upgradeDatabaseToVersion535(sqlStore *SqlStore) {
|
||||
sqlStore.CreateColumnIfNotExistsNoDefault("Channels", "LastRootPostAt", "bigint", "bigint")
|
||||
defer sqlStore.RemoveColumnIfExists("Channels", "LastRootPostAt")
|
||||
|
||||
// note: setting default 0 on pre-5.0 tables causes test-db-migration script to fail, so this column will be added to ignore list
|
||||
sqlStore.CreateColumnIfNotExists("ChannelMembers", "MsgCountRoot", "bigint", "bigint", "0")
|
||||
sqlStore.AlterColumnDefaultIfExists("ChannelMembers", "MsgCountRoot", model.NewString("0"), model.NewString("0"))
|
||||
|
||||
@@ -1122,7 +1127,4 @@ func upgradeDatabaseToVersion535(sqlStore *SqlStore) {
|
||||
mlog.Error("Error updating ChannelMembers table", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
// saveSchemaVersion(sqlStore, Version5350)
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@ func createChannelWithLastPostAt(ss store.Store, teamId, creatorId string, lastP
|
||||
m.Type = model.CHANNEL_OPEN
|
||||
return ss.Channel().Save(&m, -1)
|
||||
}
|
||||
|
||||
func TestMsgCountRootMigration(t *testing.T) {
|
||||
type TestCaseChannel struct {
|
||||
Name string
|
||||
@@ -225,7 +226,7 @@ func TestMsgCountRootMigration(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
_, err = sqlStore.GetMaster().Exec(`ALTER TABLE ChannelMembers DROP COLUMN MsgCountRoot`)
|
||||
require.NoError(t, err)
|
||||
upgradeDatabaseToVersion535(sqlStore)
|
||||
rootCountMigration(sqlStore)
|
||||
|
||||
members, err := ss.Channel().GetMembersByIds(channel.Id, userIds)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user