Hi I was trying to do migration rake db:migration
to add new table as well as new indexes.
However, I got this error:
Caused by:
ArgumentError: Index name 'index_cite_this_article_referencings_on_referencer_type_and_referencer_id' on table 'cite_this_article_referencings' is too long; the limit is 64 characters
Which is understandable, but after I define the name of index, the migration doesn't take my self-defined index name and still give the same error.
Here is my migration:
class CreateCiteThisArticleReferencings < ActiveRecord::Migration[5.2]
def change
create_table :cite_this_article_referencings do |t|
t.belongs_to :article
t.belongs_to :referencer, polymorphic: true
t.timestamps
t.index [:article_id], name: "cite_this_article_referencings_a_id", unique: true
t.index [:referencer_id], name: "cite_this_article_referencings_r_id", unique: true
t.index [:referencer_id, :referencer_type], name: "cite_this_article_referencings_all_ids", unique: true
end
end
end
The migration can't catch the cite_this_article_referencings_all_ids
; instead, it still uses its own created name index_cite_this_article_referencings_on_referencer_type_and_referencer_id
Rails 5.2.3; Ruby 2.5.1; MacOS Mojave. Thanks for any help!