Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: lib/ruby/rollup_migration.rb
- ===================================================================
- --- lib/ruby/rollup_migration.rb (revision 4910)
- +++ lib/ruby/rollup_migration.rb (working copy)
- @@ -7,7 +7,7 @@
- metrics = metadata[:field_names] - keys
- if table_exists?(sink)
- - fields = columns(sink).map{ |c| c.name }
- + fields = columns(sink).map{ |c| field_name(c.name) }
- missing_fields = fields - metadata[:field_names]
- raise "Cannot remove fields, missing: #{missing_fields.inspect}" unless missing_fields.empty?
- @@ -39,18 +39,41 @@
- end
- def self.key_column(t, name)
- - t.column name, column_type(name), :references => references(name)
- + t.column column_name(name), column_type(name), :references => references(name)
- end
- def self.metric_column(t, name)
- - t.column name, column_type(name), :null => false, :default => 0, :references => references(name)
- + t.column column_name(name), column_type(name), :null => false, :default => 0, :references => references(name)
- end
- + def self.column_name(name)
- + case name
- + when 'nyc_day_id' then 'nyc_day'
- + when 'client_day_id' then 'client_day'
- + when 'nyc_time_id' then 'nyc_time'
- + when 'client_time_id' then 'client_time'
- + else name
- + end
- + end
- +
- + # Inverse of column_name, TODO: refactor
- + def self.field_name(name)
- + case name
- + when 'nyc_day' then 'nyc_day_id'
- + when 'client_day' then 'client_day_id'
- + when 'nyc_time' then 'nyc_time_id'
- + when 'client_time' then 'client_time_id'
- + else name
- + end
- + end
- +
- # This is a hack to avoid type metadata
- def self.column_type(name)
- case name
- when 'match_score', 'cost', 'budget' then :float
- when 'match_type', 'match_algorithm' then :text
- + when 'nyc_day_id', 'client_day_id' then :date
- + when 'nyc_time_id', 'client_time_id' then :time
- else :integer
- end
- end
Add Comment
Please, Sign In to add comment