schema.rb 文件没有更新

schema.rb file is not updating

在我的应用程序中,我编辑了此处显示的迁移文件:

class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :first_name
      t.string :last_name
      t.string :dj_alias
      t.boolean :site_admin
      t.integer :station_id
      t.string :byline
      t.string :bio

      t.timestamps null: false
    end
  end
end

拥有简历和署名字段。但是,当我 运行 rake db:reset 时,schema.rb 文件没有任何变化。我看到的唯一错误是有这个代码块:

ActiveRecord::Base.connection.tables.each do |table|
  result = ActiveRecord::Base.connection.execute("SELECT id FROM #{table} ORDER BY id DESC LIMIT 1") rescue ( puts "Warning: not procesing table #{table}. Id is missing?" ; next )
  ai_val = result.any? ? result.first['id'].to_i + 1 : 1
  puts "Resetting auto increment ID for #{table} to #{ai_val}"

  ActiveRecord::Base.connection.execute("ALTER SEQUENCE #{table}_id_seq  RESTART WITH #{ai_val}")
end

在 seeds.rb 文件的底部,用于处理种子文件的索引。当我运行 rake db:reset时,第一行的rescue语句显示:Warning: not processing table schema_migrations。 ID 丢失?

我想我很困惑为什么这个声明正在拯救这个?虽然看起来可能是原因,但 schema.rb 重置不会发生在 seeds.rb 文件被访问之前吗?

这里是 rake 的输出 db:migrate:status

 Status   Migration ID    Migration Name
--------------------------------------------------
up     20150225041954  Create songs
up     20150225042739  Create albums
up     20150225043102  Create artists
up     20150225043854  Create playlists
up     20150225044118  Create users
up     20150225044314  Create stations
up     20150225061259  Create featured artists
up     20150225153938  Add devise to users
up     20150225200646  Create reviews
up     20150321171830  Stations users
up     20150323200255  Add last fm to album
up     20150323200432  Add last fm to artist
up     20150323200513  Add last fm to song
up     20150325052314  Albums stations
up     20150325061241  Playlist songs
up     20150327172516  Add image url to albums
up     20150327172532  Add image url to artists

要在迁移文件中应用新更改,您需要 运行 rake db:migrate。如果在您进行更改之前迁移已经 运行,则 运行 rake db:rollback 回滚迁移并再次应用它。

rake db:reset 不应用迁移文件中的新更改。它会尝试加载 schema.rb 文件中已有的内容。

有关 rake db:reset 工作原理的更多详细信息,请参阅 http://edgeguides.rubyonrails.org/active_record_migrations.html#setup-the-database & http://edgeguides.rubyonrails.org/active_record_migrations.html#resetting-the-database

运行 rake db:migrate:status 查看什么是迁移 运行.