Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Why do I keep getting the error seen below when running rake db:migrate...

SQLite3::CantOpenException: unable to open database file: CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")/cygdrive/c/users/daniel/workspace/ruby/rails/tesT_app/db/migrate/20130606041329_devise_create_users.rb:40:in `change'

I've followed to the letter https://github.com/plataformatec/devise#getting-started on the devise github readme, created a brand new project, and still get the error.

Created a new rail app: (success)
rails new tesT_app

Added gem 'devise' to my Gemfile: (success)
gem 'devise'

Installed the bundle: (success)
bundle install

Ran the rails generator: (success)
rails generate devise:install

Generated a devise model with the name User: (success)
rails generate devise User

I referred to the SO question at SQLite3:CantOpenException (uanble to open database file) which lead me to try using rake db:create which returned db/development.sqlite3 already exists. fine.

I then ran rake db:migrate per the getting started..: (fail)
With the error SQLite3::CantOpenException: unable to open database file: CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")/cygdrive/c/users/daniel/workspace/ruby/rails/tesT_app/db/migrate/20130606041329_devise_create_users.rb:40:inchange'`

What is happening? I am following this getting started to the letter, and cannot figure this out!

I'd really appreciate it.

edit: Line :40 on ...create_users.rb is
add_index :users, :email, :unique => true

and note that i hadn't touched anything.

share|improve this question
Have you checked the owner and permissions on your SQLite database file? – mu is too short 3 hours ago
it works for a standard rails object, but only complains with devise.. don't know if perms would be the issue? edit perms are fine – sircapsalot 3 hours ago
Could you post a copy of you migration file ? – jaybbb 2 hours ago

2 Answers

In SQLite, index name uniqueness is enforced at the database level. In MySQL you will not reproduce same issue. You can eather change index name or comment this line out (and return while deploing in production), or change database (I mean use mysql instead).

share|improve this answer

Sorry I thought you had a separated user model. Could you please post your migration file ? Also please try running

rake db:drop

(to delete your current db) then

rake db:create and rake db:migrate

That will make sure you're migrating on a brand new db.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.