所以我在 db->migrate 文件夹中创建了一个手动文件名 001_create_users.rb ,如下所示:
class CreateUsers < ActiveRecord::Base
def self.up
create_table :users do |t|
t.string :name
t.string :email
t.string :password
t.string :bio
t.timestamps
end
end
def self.down
drop_table :users
end
end
然后我运行一个 :bundle exec rake db:migrate
命令,我得到这个错误:
耙中止!发生错误,此迁移和所有后续迁移均已取消:
找不到表“create_users”
错误是更多细节,所以我只是从终端窗口复制粘贴它,但第一部分是我得到的错误的头部
耙中止!发生错误,此迁移和所有后续迁移均已取消:
找不到表'create_users'/Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/connection_adapter/sqlite_adapter.rb:472:in
table_structure' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in
columns' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/connection_adapters/schema_cache.rb:12:inblock in initialize' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:228:in
yield' /Users/JonyIve/.rvm /gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:228:indefault' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:228:in
columns' /Users/JonyIve/.rvm/gems/ruby-1.9.3- p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:243:incolumn_defaults' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/base.rb:482:in
初始化'/Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2 .11/lib/active_record/migration.rb:538:innew' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:538:in
load_migration'/Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:533:inmigration' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:528:in
migrate'/Users/JonyIve/.rvm /gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:720:inblock (2 levels) in migrate' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in
call' /Users/JonyIve/.rvm/gems/ruby-1.9.3- p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:inblock in ddl_transaction' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in
transaction' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2 .11/lib/active_record/transactions.rb:208:intransaction' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in
ddl_transaction'/Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration。 RB:719:在block in migrate' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in
每个'/Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:inmigrate' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:570:in
up'/Users/JonyIve/.rvm /gems/ruby-1.9.3-p362@railsbabak/gems/activerecord-3.2.11/lib/active_record/migration.rb:551:inmigrate' /Users/JonyIve/Documents/HisFirstService/Rakefile:19:in
block (2 levels) in ' /Users/JonyIve/.rvm/gems/ruby -1.9.3-p362@railsbabak/bin/ruby_noexec_wrapper:14:ineval' /Users/JonyIve/.rvm/gems/ruby-1.9.3-p362@railsbabak/bin/ruby_noexec_wrapper:14:in
'Tasks: TOP => db:migrate(通过使用 --trace 运行任务查看完整跟踪)
另外,如果我说“哪个宝石”,这就是我得到的:
which gem
/Users/JonyIve/.rvm/rubies/ruby-1.9.3-p362/bin/gem