From 3c21eef110026c320de1dd441ff38164f530b5bd Mon Sep 17 00:00:00 2001 From: Eli Yukelzon Date: Thu, 1 Apr 2021 13:56:39 +0300 Subject: [PATCH] MM-33746 hotfix (#17320) Co-authored-by: Mattermod --- .circleci/config.yml | 7 ++++++- scripts/mysql-migration-test.sh | 2 +- scripts/psql-migration-test.sh | 2 +- store/sqlstore/upgrade.go | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4c79511674..2d9c6ea35a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -320,9 +320,11 @@ jobs: mattermost/mattermost-build-server:20201119_golang-1.15.5 \ bash -c "ulimit -n 8096; make ARGS='version' run-cli && make MM_SQLSETTINGS_DATASOURCE='postgres://mmuser:mostest@postgres:5432/latest?sslmode=disable&connect_timeout=10' ARGS='version' run-cli" - echo "Ignoring known mismatch: ChannelMembers.MsgCountRoot" + echo "Ignoring known mismatch: ChannelMembers.MsgCountRoot and Channels.TotalMsgCountRoot" docker-compose --no-ansi exec -T postgres sh -c 'exec echo "ALTER TABLE ChannelMembers DROP COLUMN MsgCountRoot;" | exec psql -U mmuser -d migrated' docker-compose --no-ansi exec -T postgres sh -c 'exec echo "ALTER TABLE ChannelMembers DROP COLUMN MsgCountRoot;" | exec psql -U mmuser -d latest' + docker-compose --no-ansi exec -T postgres sh -c 'exec echo "ALTER TABLE Channels DROP COLUMN TotalMsgCountRoot;" | exec psql -U mmuser -d migrated' + docker-compose --no-ansi exec -T postgres sh -c 'exec echo "ALTER TABLE Channels DROP COLUMN TotalMsgCountRoot;" | exec psql -U mmuser -d latest' echo "Generating dump" docker-compose --no-ansi exec -T postgres pg_dump --schema-only -d migrated -U mmuser > migrated.sql @@ -360,6 +362,9 @@ jobs: echo "Ignoring known MySQL mismatch: ChannelMembers.MentionCountRoot" docker-compose --no-ansi exec -T mysql mysql -D migrated -uroot -pmostest -e "ALTER TABLE ChannelMembers DROP COLUMN MsgCountRoot;" docker-compose --no-ansi exec -T mysql mysql -D latest -uroot -pmostest -e "ALTER TABLE ChannelMembers DROP COLUMN MsgCountRoot;" + echo "Ignoring known MySQL mismatch: Channels.TotalMsgCountRoot" + docker-compose --no-ansi exec -T mysql mysql -D migrated -uroot -pmostest -e "ALTER TABLE Channels DROP COLUMN TotalMsgCountRoot;" + docker-compose --no-ansi exec -T mysql mysql -D latest -uroot -pmostest -e "ALTER TABLE Channels DROP COLUMN TotalMsgCountRoot;" echo "Generating dump" docker-compose --no-ansi exec -T mysql mysqldump --skip-opt --no-data --compact -u root -pmostest migrated > migrated.sql diff --git a/scripts/mysql-migration-test.sh b/scripts/mysql-migration-test.sh index 90b69a8955..6e15d28ffa 100755 --- a/scripts/mysql-migration-test.sh +++ b/scripts/mysql-migration-test.sh @@ -22,7 +22,7 @@ make ARGS="config set SqlSettings.DataSource 'mmuser:mostest@tcp(localhost:3306) echo "Setting up fresh db" make ARGS="version --config $TMPDIR/config.json" run-cli -for i in "ChannelMembers SchemeGuest" "ChannelMembers MsgCountRoot"; do +for i in "ChannelMembers SchemeGuest" "ChannelMembers MsgCountRoot" "Channels TotalMsgCountRoot"; do a=( $i ); echo "Ignoring known MySQL mismatch: ${a[0]}.${a[1]}" docker exec mattermost-mysql mysql -D migrated -uroot -pmostest -e "ALTER TABLE ${a[0]} DROP COLUMN ${a[1]};" diff --git a/scripts/psql-migration-test.sh b/scripts/psql-migration-test.sh index 368eed0b45..c5ef977bde 100755 --- a/scripts/psql-migration-test.sh +++ b/scripts/psql-migration-test.sh @@ -22,7 +22,7 @@ make ARGS="config set SqlSettings.DataSource 'postgres://mmuser:mostest@localhos echo "Setting up fresh db" make ARGS="version --config $TMPDIR/config.json" run-cli -for i in "ChannelMembers MsgCountRoot"; do +for i in "ChannelMembers MsgCountRoot" "Channels TotalMsgCountRoot"; do a=( $i ); echo "Ignoring known Postgres mismatch: ${a[0]}.${a[1]}" docker exec mattermost-postgres psql -U mmuser -d migrated -c "ALTER TABLE ${a[0]} DROP COLUMN ${a[1]};" diff --git a/store/sqlstore/upgrade.go b/store/sqlstore/upgrade.go index 8f6a070390..31a843f7f8 100644 --- a/store/sqlstore/upgrade.go +++ b/store/sqlstore/upgrade.go @@ -1011,7 +1011,7 @@ func upgradeDatabaseToVersion535(sqlStore *SqlStore) { sqlStore.CreateColumnIfNotExists("SidebarCategories", "Collapsed", "tinyint(1)", "boolean", "0") - sqlStore.CreateColumnIfNotExistsNoDefault("Channels", "TotalMsgCountRoot", "bigint", "bigint") + sqlStore.CreateColumnIfNotExists("Channels", "TotalMsgCountRoot", "bigint", "bigint", "0") sqlStore.CreateColumnIfNotExistsNoDefault("Channels", "LastRootPostAt", "bigint", "bigint") defer sqlStore.RemoveColumnIfExists("Channels", "LastRootPostAt")