Bootstrap error: relation "ai_agent_mcp_servers" does not exist -- due to migration id collision

So, here comes a bug report that ask.discourse.com wrote, but first, I want to share this bit that it offered:

I decided to let it be itself, and not “blunt and short”. :rofl: (I didn’t roll on the floor, but I did, truly, laugh out loud.

This seems like a credible report and likely better than I’d have written.

Bug report from ask . . .

Here’s a concise bug report you can post on Meta:

After updating, bootstrap fails during `db:migrate` with:

```text
PG::UndefinedTable: ERROR:  relation "ai_agent_mcp_servers" does not exist

The failing migration is:

/plugins/discourse-ai/db/migrate/20260319070000_add_selected_tool_names_to_ai_agent_mcp_servers.rb

It appears this migration tries to add a column to ai_agent_mcp_servers before that table exists.

Relevant part of the log:

== 20260319070000 AddSelectedToolNamesToAiAgentMcpServers: migrating ==========
PG::UndefinedTable: ERROR:  relation "ai_agent_mcp_servers" does not exist
...
/var/www/discourse/plugins/discourse-ai/db/migrate/20260319070000_add_selected_tool_names_to_ai_agent_mcp_servers.rb:5

This looks like a migration ordering issue in discourse-ai, or a missing earlier migration that should create ai_agent_mcp_servers.

Environment:

  • official Docker install
  • bootstrap fails on bundle exec rake db:migrate
  • plugins shown in logs include discourse-citationwizard and discourse-prometheus

Full report / logs:
Bootstrap error: relation “ai_agent_mcp_servers” does not exist