当我运行 db:migrate 任务时,迁移实际上并没有发生。这是我的 Rakefile 的代码:
namespace :db do
desc "Migrate the database through scripts in lib/generators/facebook_event_fetcher/install/templates. Target specific version with VERSION=x"
task :migrate => :environment do
ActiveRecord::Migration.verbose = true
#ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
ActiveRecord::Migrator.migrate('lib/generators/facebook_event_fetcher/install/templates', nil)
end
task :environment do
ActiveRecord::Base.establish_connection(YAML.load_file("config/database.yml"))
ActiveRecord::Base.logger = Logger.new(File.open('db/database.log', 'a'))
end
end
您可以仔细查看 Github 存储库: https ://github.com/mabounassif/facebook_event_fetcher/blob/master/Rakefile#L42
为什么不会触发迁移?