I'm trying to add indexes to 16 columns at a time, in migration:
add_index :billing_invoices, [:due_date, :flat_fee, :percentage_fee, :subtotal,
:processing_fee, :total, :invoice_number, :attn, :street_line_1, :street_line_2,
:city, :state, :zip_code, :is_deactivated, :start_date, :end_date]
But, I get this error:
Mysql2::Error: Specified key was too long; max key length is 3072 bytes: CREATE UNIQUE INDEX i ON billing_invoices (due_date, flat_fee, percentage_fee, subtotal, processing_fee, total, invoice_number, attn, street_line_1, street_line_2, city, state, zip_code, is_deactivated, start_date, end_date)
So, I tried adding :unique => true, :name => 'indexes_billing_invoices'
, as it was suggested in a SO post:
add_index :billing_invoices, [:due_date, :flat_fee, :percentage_fee, :subtotal,
:processing_fee, :total, :invoice_number, :attn, :street_line_1, :street_line_2,
:city, :state, :zip_code, :is_deactivated, :start_date, :end_date],
:unique => true, :name => 'indexes_billing_invoices'
But, still it throws the same error. Even I tried :name => 'i'
to check, but the same error comes.