views:

20

answers:

1
SQLite3::BusyException: database is locked: CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")

I get the above error when I try to migrate a migration (written below)

class AddIndexEmailUniquenessToUsers < ActiveRecord::Migration
  def self.up
    add_index :users,:email,:unique => true 
  end

  def self.down
    remove_index :users,:email
  end
end

what went wrong. I didnt do any lock kind of thing in previous transactions.

A: 

You have a running process (rails console, ./script/server, etc) which is holding open connections to the database preventing the migration from modifying a table that's in use.

Kill off those.

If you can't find an obvious culprit, try:

ps aux | grep ruby

... to see a list of ruby processes that might be holding that db session.

Winfield