Problem with uuids as primary keys
suung opened this issue · 5 comments
suung commented
Hey
Sorry, I don't know how to go further here, i found uuid support in the changelog, but yet
(byebug) parent_task.children.create(user_id: parent_task.user.id, workflow_id: parent_task.workflow.id)
*** ActiveRecord::StatementInvalid Exception: PG::UndefinedFunction: ERROR: operator does not exist: uuid = integer
LINE 5: WHERE x.descendant_id = 72337
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: INSERT INTO "task_hierarchies"
(ancestor_id, descendant_id, generations)
SELECT x.ancestor_id, '2cd4eac4-322c-47d7-91a9-73cf95eead48', x.generations + 1
FROM "task_hierarchies" x
WHERE x.descendant_id = 72337
rails 5.2.2
closure_tree-7.0.0
I will appreciate every help very much
joaocvalerio commented
did you run Task.rebuild!?
mbajur commented
seuros commented
@mbajur You need to drop the hierarchies table and recreate it with uuid types.
Add foreign keys to be sure that the columns are connect.
seuros commented
@mbajur
Either your app is using the cache or your database is not up to date.
Try to add those fkeys:
add_foreign_key "ap_object_hierarchies", "ap_objects", column: "ancestor_id"
add_foreign_key "ap_object_hierarchies", "ap_objects", column: "descendant_id"
I use UUID all the time with closure-tree
mbajur commented
Yes, sorry, that was obviously my mistake. I forgot to change parent_id column to UUID
