lib/data_miner/configuration.rb in data_miner-0.4.33 vs lib/data_miner/configuration.rb in data_miner-0.4.34
- old
+ new
@@ -126,11 +126,11 @@
DataMiner.log_info "Not recording which run touched a row."
end
import_steps.each do |step|
step.attributes.each do |_, attribute|
- DataMiner.log_or_raise "You can't have an attribute column that ends in _units (reserved): #{resource.table_name}.#{attribute.name}" if attribute.name.ends_with? '_units'
+ DataMiner.log_or_raise "You can't have an attribute column that ends in _units (reserved): #{resource.table_name}.#{attribute.name}" if attribute.name.end_with? '_units'
unless resource.column_names.include? attribute.name
missing_columns << attribute.name
end
if attribute.wants_units? and !resource.column_names.include?(units_column = "#{attribute.name}_units")
missing_columns << units_column
@@ -151,11 +151,11 @@
and **replace** the resulting file with this:
class AddMissingColumnsTo#{resource.name} < ActiveRecord::Migration
def self.up
-#{missing_columns.map { |column_name| " add_column :#{resource.table_name}, :#{column_name}, :#{column_name.ends_with?('_units') ? 'string' : 'FIXME_WHAT_COLUMN_TYPE_AM_I' }" }.join("\n") }
+#{missing_columns.map { |column_name| " add_column :#{resource.table_name}, :#{column_name}, :#{column_name.end_with?('_units') ? 'string' : 'FIXME_WHAT_COLUMN_TYPE_AM_I' }" }.join("\n") }
#{non_essential_missing_columns.map { |column_name| " add_column :#{resource.table_name}, :#{column_name}, :integer #optional" }.join("\n") }
end
def self.down
#{missing_columns.map { |column_name| " remove_column :#{resource.table_name}, :#{column_name}" }.join("\n") }
@@ -163,10 +163,10 @@
end
end
On the other hand, if you're working directly with create_table, this might be helpful:
-#{missing_columns.map { |column_name| "t.#{column_name.ends_with?('_units') ? 'string' : 'FIXME_WHAT_COLUMN_TYPE_AM_I' } '#{column_name}'" }.join("\n") }
+#{missing_columns.map { |column_name| "t.#{column_name.end_with?('_units') ? 'string' : 'FIXME_WHAT_COLUMN_TYPE_AM_I' } '#{column_name}'" }.join("\n") }
#{non_essential_missing_columns.map { |column_name| "t.integer '#{column_name}' #optional" }.join("\n") }
================================
}
end