# Error on rebuild with bookmarks\_polymorphic

**URL:** https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543
**Category:** Self-hosting
**Created:** [January 3, 2023, 10:09am UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543 "2023-01-03T10:09:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Carquo](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@Carquo](https://meta.discourse.org/u/Carquo)
#### Post date: [January 3, 2023, 10:09am UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543/1 "2023-01-03T10:09:14Z")

</div>

Hi,

i’ve an error on Rebuild :

> ## FAILED
> 
> Pups::ExecError: cd /var/www/discourse && su discourse -c ‘bundle exec rake db:migrate’ failed with return #\<Process::Status: pid 1121 exit 1\>  
> Location of failure: /usr/local/lib/ruby/gems/3.1.0/gems/pups-1.1.1/lib/pups/exec\_command.rb:117:in `spawn’  
> exec failed with the params {“cd”=\>“$home”, “hook”=\>“db\_migrate”, “cmd”=\>[“su discourse -c ‘bundle exec rake db:migrate’”]}  
> bootstrap failed with exit code 1

And with scroll up :

> PG::DependentObjectsStillExist: ERROR: cannot drop column post\_id of table bookmarks because other objects depend on it  
> DETAIL: trigger bookmarks\_polymorphic\_data\_sync on table bookmarks depends on column post\_id of table bookmarks  
> HINT: Use DROP … CASCADE to drop the dependent objects too.

How to resolve this bug?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 3, 2023, 12:36pm UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543/2 "2023-01-03T12:36:52Z")

</div>

you might want to add which branch you are targeting, whether this is `stable` or `tests-passed`?

---

<div class="post-metadata">

### Author: ![Carquo](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@Carquo](https://meta.discourse.org/u/Carquo)
#### Post date: [January 3, 2023, 2:47pm UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543/3 "2023-01-03T14:47:00Z")

</div>

Hi,

it’s tests-passed branch normally…  
I solved the problem by deleting the trigger manually. But I don’t know if that will be a problem later.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 3, 2023, 2:53pm UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543/4 "2023-01-03T14:53:23Z")

</div>

Nice. You can always enter the container and run migrations selectively if it becomes a problem.

---

<div class="post-metadata">

### Author: ![DeviceNull](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/devicenull/32/163051_2.png) [@DeviceNull](https://meta.discourse.org/u/DeviceNull)
#### Post date: [January 6, 2023, 3:29pm UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543/5 "2023-01-06T15:29:50Z")

</div>

Unfortunately on a fresh install of 3.0.0.beta16 there is no such trigger in psql that I could drop.  
Yet restoring the Backup I made from a 2.9.0.beta12 fails with the same Error.

ERROR: cannot drop column post\_id of table bookmarks because other objects depend on it  
DETAIL: trigger bookmarks\_polymorphic\_data\_sync on table bookmarks depends on column post\_id of table bookmarks

EDIT:  
Get it now - deleted trigger in the origin - updateing and restoring backups started working again - thanks for the hint

---

<div class="post-metadata">

### Author: ![Umashankar\_Ankuri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/umashankar_ankuri/32/150996_2.png) [@Umashankar\_Ankuri](https://meta.discourse.org/u/Umashankar_Ankuri)
#### Post date: [February 1, 2023, 5:37pm UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543/6 "2023-02-01T17:37:52Z")

</div>

@DeviceNull

How did you able to delete trigger?

Getting similar issue while upgrading discourse

```plaintext
Caused by:
PG::DependentObjectsStillExist: ERROR: cannot drop column post_id of table bookmarks because other objects depend on it
DETAIL: trigger bookmarks_polymorphic_data_sync on table bookmarks depends on column post_id of table bookmarks
HINT: Use DROP ... CASCADE to drop the dependent objects too.

```

---

<div class="post-metadata">

### Author: ![Umashankar\_Ankuri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/umashankar_ankuri/32/150996_2.png) [@Umashankar\_Ankuri](https://meta.discourse.org/u/Umashankar_Ankuri)
#### Post date: [February 2, 2023, 1:41am UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543/7 "2023-02-02T01:41:02Z")

</div>

Any one going through similar issue, when upgrade failing at db migrate

Did below, upgrade was success!

Start the container, since it’s stopped during upgrade

```plaintext
./launcher start app
./launcher enter app

```

Enter into psql command prompt

`sudo -u postgres psql discourse`

see the triggers

`SELECT tgname FROM pg_trigger;`

Drop the trigger

`DROP TRIGGER IF EXISTS bookmarks_polymorphic_data_sync ON bookmarks CASCADE;`

Rebuild now

`./launcher rebuild app`

---

<div class="post-metadata">

### Author: ![DeviceNull](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/devicenull/32/163051_2.png) [@DeviceNull](https://meta.discourse.org/u/DeviceNull)
#### Post date: [February 10, 2023, 12:55pm UTC](https://meta.discourse.org/t/error-on-rebuild-with-bookmarks-polymorphic/250543/8 "2023-02-10T12:55:59Z")

</div>

1. Via your terminal (i assume bash) start mysql console inside the container:  
`docker exec -i name_of_your_container mysql`

In the mysql console:  
`use discourse;`  
`DROP TRIGGER bookmarks.bookmarks_polymorphic_data;`

Leave console with  
`exit`

After that the update script can should be able to drop the column and things should run smoothly - fingers crossed.
