Cannot migrate after destroy a table

Rails 3.1.3

Hi. I thank you for your help all the time.

I had a table User (or I might have named ‘Users’ rather, but my
recollection is unclear). Since I chose to use devise rather than a
plain user table, I destroyed it.

rails destroy model user

After that, I simply installed and generated devise User, then
implemented migration

soichi% rake db:migrate
== DeviseCreateUsers: migrating

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

SQLite3::SQLException: table “users” already exists: CREATE TABLE
varchar(255) DEFAULT ‘’ NOT NULL, “encrypted_password” varchar(255)
DEFAULT ‘’ NOT NULL, “reset_password_token” varchar(255),
“reset_password_sent_at” datetime, “remember_created_at” datetime,
“sign_in_count” integer DEFAULT 0, “current_sign_in_at” datetime,
“last_sign_in_at” datetime, “current_sign_in_ip” varchar(255),
“last_sign_in_ip” varchar(255), “confirmation_token” varchar(255),
“confirmed_at” datetime, “confirmation_sent_at” datetime,
“unconfirmed_email” varchar(255), “username” varchar(255), “created_at”
datetime, “updated_at” datetime)

It says ‘users’ exists, so but rails destroy model users does not really
do anything. The problem I think was that the table was not properly
destroyed before devise was installed.

Certainly, schema.rb file has

create_table “users”, :force => true do |t|
t.integer “script_id”
t.string “username”
t.string “password”
t.string “email”
t.string “status”
t.datetime “created_at”
t.datetime “updated_at”

add_index “users”, [“script_id”], :name => “index_users_on_script_id”

I guess I need to change some files manually if any command is useless.

Could anyone help me out for completely destroying the old table?

Thanks in advance,


you could run a migration

rails g migration drop_users_table

and inside

drop_table :users

But I’m not sure if that’s the only problem (according to your log it
to be that)

Javier Q.

Thanks! Just like you said.
I have successfully migrated devise user!


If I’m no wrong if you just run the command to generate it again, it
tell you that a user migration already exists. I’m not sure if that’s
to happen (but I guess because you are trying to generate a devise

I forgot, delete the user migration :smiley:

Well, thanks I figured it out after trying to migrate a few times!