Closed alaarab closed 5 years ago
This is a common rails/mysql issue. I believe it's the reason they started labeling migrations with the rails version. I think the easiest way to solve this is to change the new commontator migration to have the same rails version (in the square brackets) as the old migration.
I'm referring to the square brackets on this line: https://github.com/lml/commontator/blob/master/db/migrate/1_add_replying_to_comments.rb#L1
A different way that should also work would be to change the type of the commontator_comments id column to bigint, which is the new default since Rails 5.1: https://github.com/rails/rails/pull/26266
This worked. Thank you.
After updating to 6.0.1 from 5.1.0, I run the following and hit this wall:
rake commontator:install
Copied migration 20190904222732_add_replying_to_comments.commontator.rb from commontatorrake db:migrate
== 20190904222732 AddReplyingToComments: migrating ============================ -- add_reference(:commontator_comments, :parent, {:foreign_key=>{:to_table=>:commontator_comments, :on_update=>:restrict, :on_delete=>:cascade}}) rake aborted! StandardError: An error has occurred, all later migrations canceled:Column
parent_id
on tablecommontator_comments
does not match columnid
oncommontator_comments
, which has typeint(11)
. To resolve this issue, change the type of theparent_id
column oncommontator_comments
to be :integer. (For examplet.integer :parent_id
). Original message: Mysql2::Error: Cannot add foreign key constraint