Thank you for your replay but simply removing polls is not a solution to duplicate records. I assume somewhere early on the import from phpbb3 was incorrect and created those records. They are valid they just have duplicate UUID’s since original imported did not check for that.
Anyway, the solution for anyone who stumbles across this issue is to do the following:
- change problematic records on post_custom_fields table to move them out of the way. It is better to do it that way instead of waiting for rebuild few minutes just to see another error.
update post_custom_fields set name = 'polls' where name = 'polls_bak';
update post_custom_fields set name = 'polls-votes' where name = 'polls-votes_bak';
-
run the rebuild app, update or whatever user is trying to do.
-
connect to the live running container after everything builds up and starts up.
-
change polls back to original naming:
update post_custom_fields set name = 'polls'_bak' where name = 'polls';
update post_custom_fields set name = 'polls-votes_bak'' where name = 'polls-votes';
- run the migration that causes the problem manually from inside the app container, note that VERSION is the number in the filename of the migration
first unrun the migration, this will do nothing as the down method does nothing to the database:
https://github.com/discourse/discourse/pull/6359/commits/6fad48cff8e296d07b37e558c2990abaa858f4d5#diff-49699961433b72c8370574ddac289b6a92a72299862962f99fb422233f530a4e
rake db:migrate:down VERSION=20180820080623
run the migration and look for the first error:
rake db:migrate:up VERSION=20180820080623
- Search the table using some database GUI for easier editing for the UUID that causes the issue:
select from post_custom_fields where value like '%your_UUID%';
-
Now the tricky part. The UUID is the identifier of the polls answer/option so what you have to do is change that UUID on row
polllest say from731ef6901e968fc3f4e785fcb9e9abe8to731ef6901e968fc3f4e785fcb9e9abe9it is highly unlikely that you fill find another one like this in your system. But after doing this you also need to find the corresponding one inpoll-votesand change it to your new one. This way you will not loose any votes or answers. -
run the migration again and look for the next error:
rake db:migrate:up VERSION=20180820080623
- repeat this process until migration completes and you have all of the polls migrated to your new tables.
I’m disappointed that no one bothered to even replay and explain what that UUID is and what it refers to. I know its open source and I know it has been years since it was committed, I’m not complaining but some sort of assistance from people actually doing comits on the official repo would be much appreciated.
Problem was solved so happy days.
Thanks!