# Migrating from MariaDB to PostgreSQL DB

**URL:** <https://forum.mattermost.com/t/migrating-from-mariadb-to-postgresql-db/14194>\
**Category:** Troubleshooting\
**Created:** [October 6, 2022, 10:25pm UTC](https://forum.mattermost.com/t/migrating-from-mariadb-to-postgresql-db/14194 "2022-10-06T22:25:21Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![GOhrner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/gohrner/32/5775_2.png) [@GOhrner](https://forum.mattermost.com/u/GOhrner)\
**Post date:** [October 18, 2022, 4:39pm UTC](https://forum.mattermost.com/t/migrating-from-mariadb-to-postgresql-db/14194/10 "2022-10-18T16:39:32Z")

</div>

Just to add info about the first trouble (challenges?) I faced with my migrated DB:

When trying to upgrade my Mattermost 7.3.0 to 7.4.0 today Mattermost Boards refused to start, its DB migration failed.

The reason was the `props` attribute (normally JSON content) in the `Users` table, where (probably during the migration) some “`null`” Strings crept in (so no `NULL` SQL values, a literal String saying “`null`”).

This was easy to fix though:

```sql
UPDATE Users SET props = '{}' WHERE props = 'null';

```

Mattermost Boards / Focalboard startet fine afterwards.

I just hope there are not much more quirks like this hidden in the migrated data… :-/ That’s something I feared could happen with a migration approach like `pg_loader`. (If I didn’t just make a stupid mistake during migration, not sure…)

To help people googling for it, the error message I got was:

```nohighlight
cannot activate plugin: error initializing the DB: driver: postgres, message: failed to execute migration, command: executing_query, originalError: pq: kann nicht aus skalarem Wert löschen, query: \n\n\n INSERT INTO Preferences (UserId, Category, Name, Value) SELECT Id, 'focalboard', 'welcomePageViewed', replace((Props->'focalboard_welcomePageViewed')::varchar, '\"', '') FROM Users WHERE Props->'focalboard_welcomePageViewed' IS NOT NULL ON CONFLICT DO NOTHING;\n INSERT INTO Preferences (UserId, Category, Name, Value) SELECT Id, 'focalboard', 'hiddenBoardIDs', replace(replace(replace((Props->'hiddenBoardIDs')::varchar, '\"[', '['), ']\"', ']'), '\\\"', '\"') FROM Users WHERE Props->'hiddenBoardIDs' IS NOT NULL ON CONFLICT DO NOTHING;\n INSERT INTO Preferences (UserId, Category, Name, Value) SELECT Id, 'focalboard', 'tourCategory', replace((Props->'focalboard_tourCategory')::varchar, '\"', '') FROM Users WHERE Props->'focalboard_tourCategory' IS NOT NULL ON CONFLICT DO NOTHING;\n INSERT INTO Preferences (UserId, Category, Name, Value) SELECT Id, 'focalboard', 'onboardingTourStep', replace((Props->'focalboard_onboardingTourStep')::varchar, '\"', '') FROM Users WHERE Props->'focalboard_onboardingTourStep' IS NOT NULL ON CONFLICT DO NOTHING;\n INSERT INTO Preferences (UserId, Category, Name, Value) SELECT Id, 'focalboard', 'onboardingTourStarted', replace((Props->'focalboard_onboardingTourStarted')::varchar, '\"', '') FROM Users WHERE Props->'focalboard_onboardingTourStarted' IS NOT NULL ON CONFLICT DO NOTHING;\n INSERT INTO Preferences (UserId, Category, Name, Value) SELECT Id, 'focalboard', 'version72MessageCanceled', replace((Props->'focalboard_version72MessageCanceled')::varchar, '\"', '') FROM Users WHERE Props->'focalboard_version72MessageCanceled' IS NOT NULL ON CONFLICT DO NOTHING;\n INSERT INTO Preferences (UserId, Category, Name, Value) SELECT Id, 'focalboard', 'lastWelcomeVersion', replace((Props->'focalboard_lastWelcomeVersion')::varchar, '\"', '') FROM Users WHERE Props->'focalboard_lastWelcomeVersion' IS NOT NULL ON CONFLICT DO NOTHING;\n\n UPDATE Users SET props = (props - 'focalboard_welcomePageViewed' - 'hiddenBoardIDs' - 'focalboard_tourCategory' - 'focalboard_onboardingTourStep' - 'focalboard_onboardingTourStarted' - 'focalboard_version72MessageCanceled' - 'focalboard_lastWelcomeVersion');\n \n\n \n\n \n\n\n

```

---

_[View the full topic](https://forum.mattermost.com/t/migrating-from-mariadb-to-postgresql-db/14194)._
