I''ve been stuck on this from the past 2-3 days. I deleted the folder, did everything right from the start, but it''s still showing the error. I''ve been following this (=>http://www.tutorialspoint.com/ruby-on-rails-2.1/rails-migrations.htm) tutorial to at least get one rails app working but to no avail. This is the error I get when I enter the command rake db:migrate: rake aborted! Mysql::Error: #42000Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX ''unique_schema_migrations'' ON ''schema_migrations'' <''version''> ******* Also, is there any way I can set MySQL as the default database rather than sqlite3 instead of entering the command ''rails -d sql library'' wheneve i want to create an app with mysql as database ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Fusi Eon wrote:> Also, is there any way I can set MySQL as the > default database rather than sqlite3You can specify mysql, but not set it as the default afaik.> instead of entering the command ''rails -d sql library'' > wheneve i want to create an app with mysql as > database ?I don''t think I''ve ever seen that command used to create a Rails app. The one I know about that causes Rails to use MySQL instead of sqlite is: rails -d mysql your_app_name HTH, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> > I don''t think I''ve ever seen that command used to create a Rails app. > The > one I know about that causes Rails to use MySQL instead of sqlite is: > > rails -d mysql your_app_name >Yep. Sorry. That''s what I meant to write. The ''m'' alphabet on the keyboard is giving me trouble. What about the MySQL error? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Fusi Eon wrote:> What about the MySQL error? > > rake aborted! > Mysql::Error: #42000Specified key was too long; max key length is 767 > bytes: CREATE UNIQUE INDEX ''unique_schema_migrations'' ON > ''schema_migrations'' <''version''>hmm what version of MySQL do you have? works fine on mine, should just be running SQL equivalent to; CREATE TABLE `schema_migrations` ( `version` varchar(255) NOT NULL, UNIQUE KEY `unique_schema_migrations` (`version`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 does that work directly in your MySQL command client? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The problem is that MySQL has a limit of 767 bytes on the length of columns used for keys. In UTF8 a varchar(255) consumes 1080 bytes. The fix is to have the indexing done on a the first part of the key, by limiting the key to so (say) the first 100 characters, by: CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version` (100) ) In ActiveRecord 2.1.0 the code which creates the index on the schema_migrations table is in connection_adapters/abstract/schema_statements.rb on line 317. This calls the "add_index" method defined on line 255. The actual sql statement used to create the index is on line 266. Change this to: execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{quoted_column_names} (100) )" ie: add the "(100)" after the column_name, and this will instruct MySQL to only build the index on the first 100 characters of this column, well under the 767 byte limit. Matthew Rudy Jacobs wrote:> Fusi Eon wrote: >> What about the MySQL error? >> >> rake aborted! >> Mysql::Error: #42000Specified key was too long; max key length is 767 >> bytes: CREATE UNIQUE INDEX ''unique_schema_migrations'' ON >> ''schema_migrations'' <''version''> > > hmm > > what version of MySQL do you have? > works fine on mine, > should just be running SQL equivalent to; > > CREATE TABLE `schema_migrations` ( > `version` varchar(255) NOT NULL, > UNIQUE KEY `unique_schema_migrations` (`version`) > ) ENGINE=InnoDB DEFAULT CHARSET=latin1 > > does that work directly in your MySQL command client?-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jon Smillie wrote:> > The problem is that MySQL has a limit of 767 bytes on the length of > columns used for keys. In UTF8 a varchar(255) consumes 1080 bytes. The > fix is to have the indexing done on a the first part of the key, by > limiting the key to so (say) the first 100 characters, by: > > CREATE UNIQUE INDEX `unique_schema_migrations` > ON `schema_migrations` (`version` (100) )if that were the case, and MySQL required that to be set explicitly, then surely everyone using rails and utf8 would have this problem. That doesn''t seem to be the case. mysql> CREATE TABLE `schema_migrations` ( `version` varchar(255) NOT NULL, UNIQUE KEY `unique_schema_migrations` (`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Query OK, 0 rows affected (0.04 sec) mysql> show create table schema_migrations; +-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | schema_migrations | CREATE TABLE `schema_migrations` ( `version` varchar(255) NOT NULL, UNIQUE KEY `unique_schema_migrations` (`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 | +-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> show variables where Variable_name = "version"; +---------------+---------+ | Variable_name | Value | +---------------+---------+ | version | 5.0.51b | +---------------+---------+ 1 row in set (0.00 sec) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jon Smillie wrote:> By way of clarification - I''m using Rails 2.1 and MySQL 6.0.4-alpha > for Win32. > > On Jul 1, 6:40 pm, Matthew Rudy Jacobs <rails-mailing-l...@andreas-Aah... MySQL 6 maybe that''s the issue, more rigid indexing maybe... Worth some investigating, you are using InnoDB and not crazy Falcon? cos it''d be poo if rails doesnt work with mysql 5.1 / 6.0 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Afrasyab Bashir wrote:> Just to add, sadly enough the solution I wrote was true only for MySQL > version 5.0.6+ :( ''cos on MySQL 6.0 it''s still a problem. > > On Jul 2, 10:42�am, Matthew Rudy Jacobs <rails-mailing-l...@andreas-By now, MySQL 6.0.7 and Rails 2.1.2 still have the problem. Mysql::Error: #42000Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`) Which one should fix the problem? MySQL or Rails team? This problem blocks Rails'' test. :( -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Still facing the issue with MySQL 6.0 and Rails 2.1.2, filed: http://bugs.mysql.com/bug.php?id=42193. -Arun Derder Ga wrote:> Afrasyab Bashir wrote: >> Just to add, sadly enough the solution I wrote was true only for MySQL >> version 5.0.6+ :( ''cos on MySQL 6.0 it''s still a problem. >> >> On Jul 2, 10:42�am, Matthew Rudy Jacobs <rails-mailing-l...@andreas- > > By now, MySQL 6.0.7 and Rails 2.1.2 still have the problem. > > Mysql::Error: #42000Specified key was too long; max key length is 767 > bytes: CREATE UNIQUE INDEX `unique_schema_migrations` ON > `schema_migrations` (`version`) > > Which one should fix the problem? MySQL or Rails team? > This problem blocks Rails'' test. > :(-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
And still a problem today wih rails 2.2.2... Arun Gupta wrote:> Still facing the issue with MySQL 6.0 and Rails 2.1.2, filed: > http://bugs.mysql.com/bug.php?id=42193. > > -Arun > > Derder Ga wrote: >> Afrasyab Bashir wrote: >>> Just to add, sadly enough the solution I wrote was true only for MySQL >>> version 5.0.6+ :( ''cos on MySQL 6.0 it''s still a problem. >>> >>> On Jul 2, 10:42�am, Matthew Rudy Jacobs <rails-mailing-l...@andreas- >> >> By now, MySQL 6.0.7 and Rails 2.1.2 still have the problem. >> >> Mysql::Error: #42000Specified key was too long; max key length is 767 >> bytes: CREATE UNIQUE INDEX `unique_schema_migrations` ON >> `schema_migrations` (`version`) >> >> Which one should fix the problem? MySQL or Rails team? >> This problem blocks Rails'' test. >> :(-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---