PostgreSQL error when migrating from 5.39.0 to 6.0.0

Summary
errors during the database schema migration of the PostgreSQL database when starting up the 6.0.0 version with a PostgreSQL 13.4 database.

mattermost_db_1  | 2021-10-13 13:09:20.210 UTC [332] ERROR:  default for column "timezone" cannot be cast automatically to type jsonb
mattermost_db_1  | 2021-10-13 13:09:20.210 UTC [332] STATEMENT:  ALTER TABLE users ALTER COLUMN timezone TYPE jsonb USING timezone::jsonb;

Steps to reproduce
using the PostgreSQL queries from

This step fails:

ALTER TABLE users ALTER COLUMN timezone TYPE jsonb USING timezone::jsonb;

Expected behavior
migration should work without errors

Observed behavior

ALTER TABLE users ALTER COLUMN timezone TYPE jsonb USING timezone::jsonb;
ERROR:  default for column "timezone" cannot be cast automatically to type jsonb

I went now back to 5.39.0

@streamer45 @agnivade ^

Confirmed. I experienced the same errors when migration from 5.38 to 6.0.

Software version:

  • psql (PostgreSQL) 11.13 (Debian 11.13-0+deb10u1).

I recovered database from the backup and went back to 5.38, awaiting for the fix.

1 Like

I was able to get this working, but I would have the MM team verify this is a fix.

On the Mattermost database (PostgreSQL)

ALTER TABLE users ALTER COLUMN timezone DROP DEFAULT;
ALTER TABLE users ALTER COLUMN timezone TYPE jsonb USING timezone::jsonb;
ALTER TABLE users ALTER COLUMN timezone SET DEFAULT '{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}';

The last one may not be correct, but after doing this I was able to get MM 6.0.0 running.

2 Likes

Thanks all. Yes, we are releasing a dot release along with a couple other fixes.

In the mean while, as a workaround, you can run:
ALTER TABLE users ALTER COLUMN timezone DROP DEFAULT;

and re-run Mattermost again.

3 Likes