4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/generators/immigration_generator.rb', line 4
def create_immigration_file
Rails.application.eager_load!
@keys, warnings = Immigrant.infer_keys
warnings.values.each{ |warning| $stderr.puts "WARNING: #{warning}" }
@keys.each do |key|
next unless key.options[:dependent] == :delete
$stderr.puts "NOTICE: #{key.options[:name]} has ON DELETE CASCADE. You should remove the :dependent option from the association to take advantage of this."
end
if @keys.present?
template = ActiveRecord::VERSION::STRING < "3.1." ? "immigration-pre-3.1.rb" : "immigration.rb"
migration_template template, "db/migrate/#{file_name}.rb"
else
puts "Nothing to do"
end
end
|