1.在 lib/task 中新建一个 install_system.rake
2. 复制这段代码
namespace :db do
namespace :migrate do
desc "Install system"
task :install_system => :environment do
raise "PLUGIN is require when specify PLUGIN_VERSION" if !ENV['PLUGIN']
plugin_path = "#{RAILS_ROOT}/vendor/plugins/#{ENV['PLUGIN']}/db/migrate"
raise "Unknown plugin: #{ENV["PLUGIN"]}" if !File.exist?(plugin_path)
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
puts plugin_path
ActiveRecord::Migrator.migrate(plugin_path)
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
end
end
end
3.
rake db:migrate:install_system PLUGIN=[插件名]