DuplicateColumn and multisite:migrate failed

Upgrading from 2.9.0.beta2 to 2.9.0.beta4 failed with error message PG::DuplicateColumn: ERROR: column "bookmarkable_id" of relation "bookmarks" already exists. The advice in Recovering from failed/partially applied upgrade helped me to get back online again. I’m starting a new topic because this issue seems to be specifically about a (dockerized) multisite install.

The issue seems to be multisite:migrate trying to run again the same migration that was already ran as part of the earlier migrations. The result was PG::DuplicateColumn: ERROR: column "bookmarkable_id" of relation "bookmarks" already exists. Based on the error message this could to be related to the polymorphic bookmarks feature, DEV: Re-add polymorphic bookmark columns by martin-brennan · Pull Request #16261 · discourse/discourse · GitHub (ping @martin?).

After running into the trouble, my quick-and-dirty cure was to:

  1. Comment out the line - exec: cd /var/www/discourse && sudo -E -u discourse bundle exec rake multisite:migrate in the configuration file containers/web_only.yml.
  2. Manually drop the (partially applied?) migrations related to bookmarks: ./launcher enter data and use psql to log in to both my Discourse databases and run ALTER TABLE bookmarks DROP COLUMN bookmarkable_id, DROP COLUMN bookmarkable_type;
  3. Re-run the rebuild: ./launcher rebuild web_only 2>&1

What might I be missing now that the multisite:migrate was not executed? I’d appreciate any thoughts. Both sites seem to work though. :crossed_fingers:

1 Like

Then I think what I would do is to run another upgrade and do if you’re out of the woods.

Any thoughts on why you’d do that? Or pointers to what to expect from running the multisite migrate? You see, I have an aversion to running scripts I don’t understand. :slightly_smiling_face:

Because you at least sort of know how to fix it and you’ll have forgotten completely when you upgrade the next time (if you are anything like me). I’m pretty sure that it’ll work, as I think that’s what others have seen when they fixed this issue

1 Like

Makes sense, it seems like you never had run the post-migrate to remove the columns that were originally there, which I removed in DEV: Re-add polymorphic bookmark columns by martin-brennan · Pull Request #16261 · discourse/discourse · GitHub. I may just need to check for the columns before re-adding them here discourse/20220322024216_add_bookmark_polymorphic_columns.rb at 037172beaae0743176eee653bd2cd4cd1ce5c7e9 · discourse/discourse · GitHub , will make a commit for that.

Just merged a commit which should help:

4 Likes