# Beginner Facing Problem with rake db:migrate

**URL:** <https://www.ruby-forum.com/t/beginner-facing-problem-with-rake-db-migrate/189341>\
**Category:** Rails\
**Created:** [May 29, 2010, 12:06am UTC](https://www.ruby-forum.com/t/beginner-facing-problem-with-rake-db-migrate/189341 "2010-05-29T00:06:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mundrakrishna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@mundrakrishna](https://www.ruby-forum.com/u/mundrakrishna)\
**Post date:** [May 29, 2010, 12:06am UTC](https://www.ruby-forum.com/t/beginner-facing-problem-with-rake-db-migrate/189341/1 "2010-05-29T00:06:26Z")

</div>

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:in`log’  
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:in`create\_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:in`block 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:in`measure’  
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:in`method\_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:in`measure’  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active\_record/migratio  
n.rb:282:in `migrate' C:1:in`migrate’  
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:in`call’  
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:in`block 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:in`migrate’  
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:in`migrate’  
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:in`call’  
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:in`each’  
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:in`block  
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:in`invoke\_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:in`invoke\_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:in`each’  
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:in`standard\_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:in`block  
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:in`run’  
C:/Ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake:31:in `<top (required)>' C:/Ruby19/bin/rake:19:in`load’  
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.

---

<div class="post-metadata">

**Author:** ![mundrakrishna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@mundrakrishna](https://www.ruby-forum.com/u/mundrakrishna)\
**Post date:** [May 29, 2010, 12:20am UTC](https://www.ruby-forum.com/t/beginner-facing-problem-with-rake-db-migrate/189341/2 "2010-05-29T00:20:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mundrakrishna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@mundrakrishna](https://www.ruby-forum.com/u/mundrakrishna)\
**Post date:** [May 29, 2010, 12:33am UTC](https://www.ruby-forum.com/t/beginner-facing-problem-with-rake-db-migrate/189341/3 "2010-05-29T00:33:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mundrakrishna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@mundrakrishna](https://www.ruby-forum.com/u/mundrakrishna)\
**Post date:** [May 29, 2010, 12:41am UTC](https://www.ruby-forum.com/t/beginner-facing-problem-with-rake-db-migrate/189341/4 "2010-05-29T00:41:21Z")

</div>

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](http://www.ruby-forum.com/topic/157223)

Good luck!

---

<div class="post-metadata">

**Author:** ![mundrakrishna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@mundrakrishna](https://www.ruby-forum.com/u/mundrakrishna)\
**Post date:** [May 29, 2010, 9:52am UTC](https://www.ruby-forum.com/t/beginner-facing-problem-with-rake-db-migrate/189341/5 "2010-05-29T09:52:00Z")

</div>

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.
