ruby on rails - Error on migration: SQLite3::SQLException: no such table: main.users -
i'm still pretty new rails world. i've been working on skill @ time thought i'd give omni-auth twitter crack. i've been reading through tutorial on sitepoint:
rails authentication oauth 2.0 , omniauth
i'm find until point has me create user model , modify migration file before running rake db:migrate
. here's migration file based on instructions:
class createusers < activerecord::migration def change create_table :users |t| t.string :provider, null: false t.string :uid, null: false t.string :name t.string :location t.string :image_url t.string :url add_index :users, :providers add_index :users, :uid add_index :users, [:provider, :uid], unique: true t.timestamps null: false end end end
but when run rake db:migrate
throws error:
sqlite3::sqlexception: no such table: main.users: create index "index_users_on_providers" on "users" ("providers")/users/jrshafer/.rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.11/lib/sqlite3/database.rb:91:in `initialize'
any provide aspiring developer appreciated.
you can view full repo here: kronotweeter github repo
you should create table in 1 block , add indexes. in current code, trying add indexes in same create_table
block.
try replacing current code piece of code:
class createusers < activerecord::migration def change create_table :users |t| t.string :provider, null: false t.string :uid, null: false t.string :name t.string :location t.string :image_url t.string :url t.timestamps null: false end # have end create_table block here # have have add_index statements add_index :users, :providers add_index :users, :uid add_index :users, [:provider, :uid], unique: true end end
then run:
bundle exec rake db:migrate
this should fix problem.
Comments
Post a Comment