Resolving pgloader Migration Error: "Threads.teamid" Column Not Found

Applies to: Mattermost v7.7 and later

Symptoms: pgloader migration fails with "Threads.teamid" column not found error

🛑 Problem

During a MySQL to PostgreSQL migration using pgloader, the migration fails with an error indicating that the Threads.teamid column cannot be found in the target "mattermost"."threads" table.

This issue typically occurs after migrating from MariaDB to MySQL, where the Mattermost v7.7 migration may not have applied correctly, resulting in an incorrect database schema.

Symptoms

Users experiencing this issue will see:

ERROR: column "Threads.teamid" not found in target table "mattermost"."threads"

Additional symptoms:

  • pgloader migration process fails to complete
  • Threads table contains incorrect TeamID column instead of ThreadTeamID
  • Schema inconsistency detected after MariaDB to MySQL migration

 

âś… Solution

Before attempting the PostgreSQL migration, correct the MySQL/MariaDB schema by removing the incorrect column.

Root Cause

The Threads table contains an incorrect column (TeamID) that should not exist in the schema. The correct column name should be ThreadTeamID.

This schema inconsistency may result from:

  • Incomplete or incorrect migration from MariaDB to MySQL
  • Custom build modifications
  • Schema corruption from a previous migration attempt

Step 1: Back up your database

Create a backup of your database before making schema changes:

mysqldump -u [username] -p [database_name] > backup_before_fix.sql

Step 2: Remove the incorrect column

ALTER TABLE Threads DROP COLUMN TeamID;

Step 3: Verify the schema

DESCRIBE Threads;

Ensure that ThreadTeamID exists and TeamID does not.

Step 4: Proceed with PostgreSQL migration

Once the schema is corrected, retry the pgloader migration to PostgreSQL.

⚠️ Important: Always create a complete database backup before modifying schema or performing migrations. Test the migration process in a non-production environment first.

Additional Resources

For more information, see:

Mattermost PostgreSQL Migration Documentation

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.