您應該能夠使用
rake db:migrate:up
,迫使它往前走,但你在你的團隊
如果您運行的風險與其他人失蹤交錯遷移
rake db:migrate
兩次,它會重新應用您的所有遷移。
我在Windows上遇到與SQLite相同的行爲,它可能是特定於此類環境的錯誤。
編輯 - 我找到了原因。在鐵軌數據庫中。rake任務,你有下面的代碼:
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
task :migrate => :environment do
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
end
在我的環境變量
然後,我有
echo %Version% #=> V3.5.0f
在Ruby中
ENV["VERSION"] # => V3.5.0f
ENV["VERSION"].to_i #=>0 not nil !
因此耙任務調用
ActiveRecord::Migrator.migrate("db/migrate/", 0)
並在主動記錄::遷移,我們有:
class Migrator#:nodoc:
class << self
def migrate(migrations_path, target_version = nil)
case
when target_version.nil? then up(migrations_path, target_version)
when current_version > target_version then down(migrations_path, target_version)
else up(migrations_path, target_version)
end
end
是,rake db:migrate VERSION=0
是長版rake db:migrate:down
編輯 - 我會去更新燈塔錯誤,但我在中超公司代理禁止,我連有
與此同時,您可能會嘗試在調用遷移之前取消設置版本...