Uuid support
Jellyfishboy opened this issue · 2 comments
Jellyfishboy commented
If you are running uuid
in your schema, you can run this migration to make the gem work with your setup:
drop_table :commontator_comments
drop_table :commontator_subscriptions
drop_table :commontator_threads
drop_table :votes
create_table :commontator_threads, id: :uuid do |t|
t.uuid :commontable_id
t.string :commontable_type
t.uuid :closer_id
t.string :closer_type
t.datetime :closed_at
t.timestamps null: false
t.index ["closer_type", "closer_id"], name: "index_commontator_threads_on_closer_type_and_closer_id"
t.index ["commontable_type", "commontable_id"], name: "index_commontator_threads_on_c_id_and_c_type", unique: true
end
create_table :commontator_comments, id: :uuid do |t|
t.uuid :thread_id, null: false
t.string :creator_type, null: false
t.uuid :creator_id, null: false
t.string :editor_type
t.uuid :editor_id
t.text "body", null: false
t.datetime "deleted_at"
t.integer "cached_votes_up", default: 0
t.integer "cached_votes_down", default: 0
t.timestamps null: false
t.uuid :parent_id
t.index ["cached_votes_down"], name: "index_commontator_comments_on_cached_votes_down"
t.index ["cached_votes_up"], name: "index_commontator_comments_on_cached_votes_up"
t.index ["creator_id", "creator_type", "thread_id"], name: "index_commontator_comments_on_c_id_and_c_type_and_t_id"
t.index ["editor_type", "editor_id"], name: "index_commontator_comments_on_editor_type_and_editor_id"
t.index ["parent_id"], name: "index_commontator_comments_on_parent_id"
t.index ["thread_id", "created_at"], name: "index_commontator_comments_on_thread_id_and_created_at"
end
create_table "commontator_subscriptions", id: :uuid do |t|
t.uuid "thread_id", null: false
t.string "subscriber_type", null: false
t.uuid "subscriber_id", null: false
t.timestamps null: false
t.index ["subscriber_id", "subscriber_type", "thread_id"], name: "index_commontator_subscriptions_on_s_id_and_s_type_and_t_id", unique: true
t.index ["thread_id"], name: "index_commontator_subscriptions_on_thread_id"
end
create_table "votes", id: :uuid do |t|
t.string "votable_type"
t.uuid "votable_id"
t.string "voter_type"
t.uuid "voter_id"
t.boolean "vote_flag"
t.string "vote_scope"
t.integer "vote_weight"
t.timestamps null: false
t.index ["votable_id", "votable_type", "vote_scope"], name: "index_votes_on_votable_id_and_votable_type_and_vote_scope"
t.index ["voter_id", "voter_type", "vote_scope"], name: "index_votes_on_voter_id_and_voter_type_and_vote_scope"
end
add_foreign_key "commontator_comments", "commontator_comments", column: "parent_id", on_update: :restrict, on_delete: :cascade
add_foreign_key "commontator_comments", "commontator_threads", column: "thread_id", on_update: :cascade, on_delete: :cascade
add_foreign_key "commontator_subscriptions", "commontator_threads", column: "thread_id", on_update: :cascade, on_delete: :cascade
Dantemss commented
Wouldn't add_reference
take care of figuring out if the foreign keys should be uuids? Or is Rails just not smart enough to do that?
Jellyfishboy commented
@Dantemss from experience, it does not.