Beginner Facing Problem with rake db:migrate

I am beginner for this Rails from the past 2 days I am working hard
to fix the following error

C:\Murali Rubby\demo\library>rake db:migrate --trace
(in C:/Murali Rubby/demo/library)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== CreateBooks: migrating

– create_table(:books)
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: Table ‘books’ already exists: CREATE TABLE books (id
int(11) D
EFAULT NULL auto_increment PRIMARY KEY, created_at datetime,
updated_at date
time) ENGINE=InnoDB
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti
on_adapters/abstract_adapter.rb:219:in rescue in log' C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti on_adapters/abstract_adapter.rb:202:inlog’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti
on_adapters/mysql_adapter.rb:323:in execute' C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti on_adapters/abstract/schema_statements.rb:114:increate_table’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/connecti
on_adapters/mysql_adapter.rb:476:in create_table' C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio n.rb:352:inblock in method_missing’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio
n.rb:328:in block in say_with_time' C:/Ruby19/lib/ruby/1.9.1/benchmark.rb:294:inmeasure’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio
n.rb:328:in say_with_time' C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio n.rb:348:inmethod_missing’
C:/Murali
Rubby/demo/library/db/migrate/20100528200605_create_books.rb:3:in `up’

C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio
n.rb:282:in block in migrate' C:/Ruby19/lib/ruby/1.9.1/benchmark.rb:294:inmeasure’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio
n.rb:282:in migrate' C:1:inmigrate’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio
n.rb:486:in block (2 levels) in migrate' C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio n.rb:562:incall’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio
n.rb:562:in ddl_transaction' C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio n.rb:485:inblock in migrate’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio
n.rb:472:in each' C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio n.rb:472:inmigrate’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio
n.rb:400:in up' C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/migratio n.rb:383:inmigrate’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.5/lib/tasks/databases.rake:116:in
block (2 levels) in <top (required)>' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:incall’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in block in execu te' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:ineach’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in
execute' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:inblock
in invok
e_with_call_chain’
C:/Ruby19/lib/ruby/1.9.1/monitor.rb:190:in mon_synchronize' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_ca
ll_chain’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:in
invoke' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in block (2 leve ls) in top_level' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:ineach’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in block in top_ level' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exce
ption_handling’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:in
top_level' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:inblock
in run’

C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exce ption_handling' C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:inrun’
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake:31:in <top (required)>' C:/Ruby19/bin/rake:19:inload’
C:/Ruby19/bin/rake:19:in `’

I spend almost like 20 hrs but I didn’t find the way to fix it.

I am working on the example given in the tutorialpoint website…
Please help me … Thanks in advance for your time.

It looks like your mysql database already has a ‘books’ table. So
either manually reset the database (and the schema) or run the
appropriate rake tasks to undo what you’ve done…

If you don’t care about any of the data in there you could do

rake db:drop db:create db:migrate

to get back to this point… type “rake -T db” to see your other
options

Hi Philip,

Earlier I manual dropped all the tables that didn’t fix the problem
Now used rake db:drop db:create db:migrate but still geting rake
aborted message…

C:\Murali Rubby\demo\library>rake db:drop db:create db:migrate

(in C:/Murali Rubby/demo/library)
rake aborted!
Mysql::Error: Specified key was too long; max key length is 767 bytes:
CREATE UN
IQUE INDEX unique_schema_migrations ON schema_migrations (version)

(See full trace by running task with --trace)

So please provide some other Info to fix that…

Thank you so much for your quick reply.

On May 28, 2010, at 3:33 PM, Krishna Venkata wrote:

Mysql::Error: Specified key was too long; max key length is 767 bytes:
CREATE UN
IQUE INDEX unique_schema_migrations ON schema_migrations (version)

(See full trace by running task with --trace)

So please provide some other Info to fix that…

Heh. Google for your mysql error and you’ll find this thread which is
exactly the same problem… even down to the same tables…

http://www.ruby-forum.com/topic/157223

Good luck!

Hi Philip,

Earlier I manual dropped all the tables that didn’t fix the problem
Now used rake db:drop db:create db:migrate but still geting rake
aborted
message…

C:\Murali Rubby\demo\library>rake db:drop db:create db:migrate
(in C:/Murali Rubby/demo/library)
rake aborted!
Mysql::Error: Specified key was too long; max key length is 767 bytes:
CREATE UN
IQUE INDEX unique_schema_migrations ON schema_migrations (version)

(See full trace by running task with --trace)

So please provide some other Info to fix that…

Thank you so much for your quick reply.