migrate
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
- #!/usr/bin/env ruby
- require 'optparse'
- require File.dirname(__FILE__) + '/../config/boot'
- options = { :environment => (ENV['RUBY_ENV'] || "development").dup }
- ARGV.options do |opts|
- script_name = File.basename($0)
-
- opts.banner = "Usage: migrate [options]"
- opts.separator ""
-
- opts.on("-e", "--environment=name", String,
- "Specifies the environment to migrate (test/development/production).",
- "Default: development") { |options[:environment]| }
-
- opts.separator ""
-
- opts.on("-h", "--help",
- "Show this help message.") { puts opts; exit }
-
- end
- ENV["RAILS_ENV"] = options[:environment]
- RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
- require RAILS_ROOT + '/config/environment'
- ActiveRecord::Migrator.migrate(RAILS_ROOT + "db/migrate/",
- ENV["VERSION"] ? ENV["VERSION"].to_i : nil )