Recovering from failed/partially applied upgrade

I attempted to upgrade my Discourse instance, however due to a handful of issues, it seems to have failed in a partially applied state. When running ./launcher rebuild app, I get the following error message, which indicates to me a migration that was already (partially) applied:

I, [2022-03-24T21:13:16.043071 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateColumn: ERROR:  column "bookmarkable_id" of relation "bookmarks" already exists

Any guidance on if there’s a way to recover from this (or if I need to bite the bullet and do a fresh install) would be appreciated. Thanks!

1 Like

You can do a

 ./launcher start app

To start the old container. That’ll get you back up.


Yep, I’m aware of that (and have done so) - however, I’m wondering what my next move should be as far as upgrading.


Oh. That wasn’t helpful then :person_shrugging:

I had a similar problem, but it seems unlikely my solution will help you.

You don’t have SKIP_POST_DEPLOYMENT_MIGRATIONS set in your app.yml do you? If so, you need to migrate the database with it set to zero and then rebuild, but I don’t think that’s your issue.

No, doesn’t look it.

That’s what I thought. So there might be an actual problem that has to do with being able to migrate from one particular point to the current one. But that’s not supposed to happen.

Check this out:

I emptied all the tables that were giving me errors (one by one, in the end there were 7), until I could rebuild app without any error.

In your case it seems that the problem is a column:

PG::DuplicateColumn: ERROR: column "bookmarkable_id" of relation "bookmarks" already exists

Maybe you should look for which table it belongs to, to be able to empty it, or you can simply drop that column.

I believe that the problem is in that when migrating partially, those tables are already created, hence it cannot create them again and it returns an error. Perhaps a conditional could be added to this process, so that it does not give errors? (I am not an expert) @pfaffman

Sounds right, @undasein.

I think that you want to remove the bookmarkable_id column from the bookmarks table. So after you get into the container and into postgres like this:

cd /var/discourse
./launcher enter app
su - postgres

Then you would

ALTER TABLE bookmarks 
DROP COLUMN bookmarkable_id
DROP COLUMN bookmarkable_type;

But taking a database-only backup wouldn’t be a bad idea of the forum is running. If not, you can do a backup with discourse backup after the enter app line above.

1 Like

Same issue here! Is this the correct solution to follow?

That was my guess. You can give it a shot and let us know.

I’m not discourse savvy.

@sam any ideas how to go forward? Standard install and upgrade turns out to be a nightmare.

Is the above the correct way to fix this issue?


didn’t work unfortunately, still getting

PG::DuplicateColumn: ERROR:  column "bookmarkable_id" of relation "bookmarks" already exists

Was there anymore action to take after these commands?

ALTER TABLE bookmarks 
DROP COLUMN bookmarkable_id
DROP COLUMN bookmarkable_type;

Thank you for your assistance

Hi Nick,
I trying to reproduce this, what is the commit of your instance?
you could try with

version: cd7ce52138bed391d5efc56366e7a6517a6079e7

in your app.yml, that’s 10 days ago, just before the redo of a reverted commit that seems to have had similar issues.


Morning Ben,

Would it be possible to give me the run through of commands to do this please?

I can update and all that easy but this is the first time something has gone wrong and to be honest I’m totally out of my comfort zone lol

Could you ./launcher start app and check the installed version in https://your.domain/admin so I can try to retrace your steps. Any plugin ?


Hi Ben,

Installed Version: 2.9.0.beta2

Installed Plugins:


./launcher start app
-bash: ./launcher: No such file or directory
 cd /var/discourse


./launcher start app

So, i noticed that i had a few ubuntu updates so everything on server is up to date

tried again and still

PG::DuplicateColumn: ERROR:  column "bookmarkable_id" of relation "bookmarks" already exists

This seems like a likely solution. You should be able to upgrade to this one and maybe then you can get to the current version? Something like that makes sense to me.

1 Like