lib/data_miner/configuration.rb in data_miner-0.4.10 vs lib/data_miner/configuration.rb in data_miner-0.4.11
- old
+ new
@@ -36,11 +36,11 @@
finished = false
if DataMiner::Run.table_exists?
run = DataMiner::Run.create! :started_at => Time.now, :resource_name => resource.name if DataMiner::Run.table_exists?
else
- DataMiner.logger.info "Not logging individual runs. Please run DataMiner::Run.create_tables if you want to enable this."
+ DataMiner.log_info "Not logging individual runs. Please run DataMiner::Run.create_tables if you want to enable this."
end
resource.delete_all if options[:from_scratch]
begin
runnables.each { |runnable| runnable.run(run) }
finished = true
@@ -93,10 +93,20 @@
end
end
def suggest_missing_column_migrations
missing_columns = Array.new
+ non_essential_missing_columns = Array.new
+ unless resource.column_names.include?('data_miner_touch_count')
+ non_essential_missing_columns << 'data_miner_touch_count'
+ DataMiner.log_info "Not counting how many times a row has been touched by data_miner."
+ end
+ unless resource.column_names.include?('data_miner_last_run_id')
+ non_essential_missing_columns << 'data_miner_last_run_id'
+ DataMiner.log_info "Not recording which run touched a row."
+ end
+
import_runnables.each do |runnable|
runnable.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'
unless resource.column_names.include? attribute.name
missing_columns << attribute.name
@@ -121,19 +131,22 @@
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") }
+#{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") }
+#{non_essential_missing_columns.map { |column_name| " remove_column :#{resource.table_name}, :#{column_name} #optional" }.join("\n") }
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") }
+#{non_essential_missing_columns.map { |column_name| "t.integer '#{column_name}' #optional" }.join("\n") }
================================
}
end
end