Reputation: 19
new to ROR. i'm taking one month rails and :
i cannot get past f'n $ rake db:migrate!!!!
I'm getting this message now
gregs-MacBook-Air:trydah gregfrontiero
$ rake db:migrate
== 20140606025644 AddDeviseToUsers: migrating =================================
-- change_table(:users)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: no such table: users: ALTER TABLE "users" ADD "email" varchar(255) DEFAULT '' NOT NULL/Users/gregfrontiero/.rvm/gems/ruby-2.1.2/gems/sqlite3-1.3.9/lib/sqlite3/database.rb:91:in
initialize' "`
I saw something on StackOverflow saying to reset and got this:
gregs-MacBook-Air:trydah gregfrontiero$ rake db:reset
/Users/gregfrontiero/Desktop/trydah/db/schema.rb doesn't exist yet. Run
rake db:migrateto create it, then try again. If you do not intend to use a database, you should instead alter /Users/gregfrontiero/Desktop/trydah/config/application.rb to limit the frameworks that will be loaded.
If you let me know how to fix this, i will build several shrines in your honor.
Thanks again,
Greg
Upvotes: 1
Views: 1914
Reputation: 76784
As mentioned in the comments, the error clearly states this:
no such table: users
The problem you have is you're trying to change a table which does not exist. If you have created the table in previous migrations & deleted on your server, you may want to use rake db:reset
, however as you've already used that command with errors, you'll probably have to set up a new table.
--
I think you'll be best doing this:
$ rails g migration CreateUserTable
#db/[timestamp]_create_users.rb
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
#... columns here
t.timestamps
end
end
end
If you then remove the content out of the migration you have currently - allowing you to run this new one, you'll be able to create the database by running rake db:migrate
. After that, you need to create a new migration, copy the commented-out one, and paste into the new one.
This will allow you to run the change
commands in your database, as the db will be present on the system.
Upvotes: 4
Reputation: 621
Maybe try starting with:
rake db:setup
then
rake db:migrate
Also, if you have setup Devise before you've created your database, you may need to comment out the devise_for :users
line in your routes.rb.
When your rails environment is loaded during rake
it loads routes, which calls this devise_for :users
which is looking for your users table, which doesn't yet exist and is the very thing that you're trying to create.
Upvotes: 0