Class: ActiveRecord::Acts::Partitioned::Structure
- Inherits:
-
Migration
- Object
- Migration
- ActiveRecord::Acts::Partitioned::Structure
- Defined in:
- lib/active_record/acts/partitioned/structure.rb
Class Method Summary collapse
- .determine_column_type(model, column) ⇒ Object
- .init_partition_catalog(model, keys, options = {}) ⇒ Object
Class Method Details
.determine_column_type(model, column) ⇒ Object
21 22 23 24 25 |
# File 'lib/active_record/acts/partitioned/structure.rb', line 21 def self.determine_column_type(model, column) found = model.columns.detect { |c| c.name == column.to_s } raise "No such column '#{column}' on model '#{model}'" unless found found.type end |
.init_partition_catalog(model, keys, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/active_record/acts/partitioned/structure.rb', line 5 def self.init_partition_catalog(model, keys, = {}) create_table("#{model.table_name}_partitions", :force => [:force]) do |t| keys.each do |key| case key.type when :discrete t.column key.column, determine_column_type(model, key.column) when :continuous t.column "#{key.column}_begin", determine_column_type(model, key.column) t.column "#{key.column}_end", determine_column_type(model, key.column) t.column "#{key.column}_exclusive", :boolean end end # TODO: Add key columns and indexes end end |