Class: PgPartitioning::PartitioningMaster
- Inherits:
-
Object
- Object
- PgPartitioning::PartitioningMaster
- Includes:
- Printer
- Defined in:
- lib/pg_partitioning/partitioning_master.rb
Constant Summary collapse
- MODES =
%w(equal step date).freeze
Constants included from Printer
PgPartitioning::Printer::COLORS
Instance Method Summary collapse
-
#initialize(table_name, column_name, mode, cond = nil) ⇒ PartitioningMaster
constructor
A new instance of PartitioningMaster.
- #partitioning ⇒ Object
Methods included from Printer
#alert, #info, #message, #print_row, #text_color
Constructor Details
#initialize(table_name, column_name, mode, cond = nil) ⇒ PartitioningMaster
Returns a new instance of PartitioningMaster.
12 13 14 15 16 17 18 19 20 |
# File 'lib/pg_partitioning/partitioning_master.rb', line 12 def initialize(table_name, column_name, mode, cond=nil) @table_name = table_name @column_name = column_name @cond = cond @sql = ActiveRecord::Base.connection() klass = "PgPartitioning::Strategies::#{MODES[mode].classify}" @strategy = klass.constantize.new(@table_name, @column_name, @cond, @sql) end |
Instance Method Details
#partitioning ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pg_partitioning/partitioning_master.rb', line 22 def partitioning @strategy.partitioning! drop_foreign_keys migration mode = show_value_of('constraint_exclusion') if mode != 'partition' alert I18n.t('pg_partitioning.messages.partition_mode', current: mode) end info I18n.t 'pg_partitioning.progress.finish' rescue => e alert e. || I18n.t('pg_partitioning.failure.other') end |