Sha256: a6a728c71e7db96ded57f289959fdc3b438595c24086c88a4cd2190ce51139e4

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'pg_partitioner/version'
require 'pg_partitioner/separation_type/base'
require 'pg_partitioner/separation_type/week'
require 'pg_partitioner/separation_type/month'
require 'pg_partitioner/separation_type/quater'

module PgPartitioner
  def self.extended(base)
    base.extend(
      PgPartitioner::SeparationType::Base,
      PgPartitioner::SeparationType::Week,
      PgPartitioner::SeparationType::Month,
      PgPartitioner::SeparationType::Quater
    )
  end

  # Template method
  # Column which will determine partition for row (must be date or datetime type). Default value is :created_at
  def parting_column
    :created_at
  end

  # Template method
  def partition_table_indexes; end

  def partition_table_named_indexes; end

  # Template method
  def partition_table_unique_indexes; end

  # Template method
  def partition_table_named_unique_indexes; end

  private

  def execute_sql(sql_string)
    connection.execute(sql_string)
  end

  def create_custom_index(table_name, index_fields, is_unique = false)
    ActiveRecord::Migration.add_index table_name, index_fields, unique: is_unique
  end

  def create_custom_named_index(table_name, index_fields, name, is_unique = false)
    ActiveRecord::Migration.add_index table_name, index_fields, name: name, unique: is_unique
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pg_partitioner-0.5.3 lib/pg_partitioner.rb
pg_partitioner-0.5.2 lib/pg_partitioner.rb
pg_partitioner-0.5.1 lib/pg_partitioner.rb
pg_partitioner-0.5.0 lib/pg_partitioner.rb