# Cannot migrate database, strange error!

**URL:** <https://www.ruby-forum.com/t/cannot-migrate-database-strange-error/193757>\
**Category:** Rails\
**Created:** [August 23, 2010, 11:40pm UTC](https://www.ruby-forum.com/t/cannot-migrate-database-strange-error/193757 "2010-08-23T23:40:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakx12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jakx12](https://www.ruby-forum.com/u/jakx12)\
**Post date:** [August 23, 2010, 11:40pm UTC](https://www.ruby-forum.com/t/cannot-migrate-database-strange-error/193757/1 "2010-08-23T23:40:13Z")

</div>

Im using restful authentication, and i changed the username model from  
login to username. The error is Mysql::Error: Key column ‘login’ doesn’t  
exist in table: CREATE UNIQUE INDEX `index_users_on_login` Heres the  
trace:

# DEPRECATION WARNING: Rake tasks in vendor/plugins/restful-authentication/tasks are deprecated. Use lib/tasks instead. (called from /Users/Zack/.gem/ruby/1.8/gems/rails-2.3.8/lib/tasks/rails.rb:10) \*\* Invoke db:migrate (first\_time) \*\* Invoke environment (first\_time) \*\* Execute environment \*\* Execute db:migrate == CreateUsers: migrating

– create\_table(“users”, {:force=\>true})  
-\> 0.1138s  
– add\_index(:users, :login, {:unique=\>true})  
rake aborted!  
An error has occurred, all later migrations canceled:

Mysql::Error: Key column ‘login’ doesn’t exist in table: CREATE UNIQUE  
INDEX `index_users_on_login` ON `users` (`login`)  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/connection\_adapters/abstract\_adapter.rb:221:in  
`log' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/mysql_adapter.rb:323:in`execute’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/connection\_adapters/abstract/schema\_statements.rb:291:in  
`add_index' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:352:in`send’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/migration.rb:352:in  
`method_missing' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:328:in`say\_with\_time’  
/opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:328:in`say\_with\_time’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/migration.rb:348:in  
`method_missing' ./db/migrate//20100823072211_create_users.rb:21:in`up\_without\_benchmarks’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/migration.rb:282:in  
`send' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:282:in`migrate’  
/opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:282:in`migrate’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/migration.rb:365:in  
` __send__' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:365:in`migrate’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/migration.rb:491:in  
`migrate' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:567:in`call’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/migration.rb:567:in  
`ddl_transaction' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:490:in`migrate’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/migration.rb:477:in  
`each' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:477:in`migrate’  
/Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active\_record/migration.rb:401:in  
`up' /Users/Zack/.gem/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/migration.rb:383:in`migrate’  
/Users/Zack/.gem/ruby/1.8/gems/rails-2.3.8/lib/tasks/databases.rake:112  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in`execute’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in`execute’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in  
`invoke_with_call_chain' /opt/local/lib/ruby/1.8/monitor.rb:242:in`synchronize’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in  
`invoke_with_call_chain' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in`invoke’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in  
`invoke_task' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in`top\_level’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in`top\_level’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in  
`standard_exception_handling' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in`top\_level’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in`standard\_exception\_handling’  
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 /opt/local/bin/rake:19:in`load’  
/opt/local/bin/rake:19

---

<div class="post-metadata">

**Author:** ![jakx12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jakx12](https://www.ruby-forum.com/u/jakx12)\
**Post date:** [August 24, 2010, 10:01am UTC](https://www.ruby-forum.com/t/cannot-migrate-database-strange-error/193757/2 "2010-08-24T10:01:05Z")

</div>

On 23 August 2010 22:40, Zack N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Im using restful authentication, and i changed the username model from  
> login to username. The error is Mysql::Error: Key column ‘login’ doesn’t  
> exist in table: CREATE UNIQUE INDEX `index_users_on_login` Heres the  
> trace:

If you are only just starting with Resful Authentication I would  
suggest not doing this, it is generally considered not the best  
nowadays. Have a look at Authlogic instead.

> ====================================================  
> – create\_table(“users”, {:force=\>true})  
> → 0.1138s  
> – add\_index(:users, :login, {:unique=\>true})  
> rake aborted!  
> An error has occurred, all later migrations canceled:
> 
> Mysql::Error: Key column ‘login’ doesn’t exist in table: CREATE UNIQUE  
> INDEX `index_users_on_login` ON `users` (`login`)

In the migration have you added the login field to the database? This  
must be done before adding the index. The clue is in the error  
message.

Colin
