I am working on Ruby on Rails project.
I am using MySQL2 as an adapter.
This is the one of migrations file.
class CreatePages < ActiveRecord::Migration[6.0]
def change
create_table :pages do |t|
t.string :base_url, null: false
t.string :html, null: false
t.string :styles, null: false
t.text :images, null: false
t.timestamps
end
add_index :pages, [:base_url, :html, :styles, :images], length: { images: 767 }, unique: true
end
end
rake db:migrate
I am getting this error.
Mysql2::Error: Specified key was too long; max key length is 767 bytes
/home/ubuntu/project/db/migrate/20200504001308_create_pages.rb:12:in `change'
Caused by:
ActiveRecord::StatementInvalid: Mysql2::Error: Specified key was too long; max key length is 767 bytes
/home/ubuntu/project/db/migrate/20200504001308_create_pages.rb:12:in `change'
Caused by:
Mysql2::Error: Specified key was too long; max key length is 767 bytes
/home/ubuntu/project/db/migrate/20200504001308_create_pages.rb:12:in `change'
Can anyone help me?