class Sequel::Postgres::CreatePartitionOfTableGenerator

  1. lib/sequel/adapters/shared/postgres.rb
Superclass: Object

Generator used for creating tables that are partitions of other tables.

Constants

MAXVALUE = Sequel.lit('MAXVALUE').freeze  
MINVALUE = Sequel.lit('MINVALUE').freeze  

Public Class methods

new(&block)
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
203 def initialize(&block)
204   instance_exec(&block)
205 end

Public Instance methods

default()

Sets that this is a default partition, where values not in other partitions are stored.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
248 def default
249   @default = true
250 end
from(*v)

Assumes range partitioning, sets the inclusive minimum value of the range for this partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
221 def from(*v)
222   @from = v
223 end
hash_values()

The modulus and remainder to use for this partition for a hash partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
263 def hash_values
264   [@modulus, @remainder]
265 end
list()

The values to include in this partition for a list partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
258 def list
259   @in
260 end
maxvalue()

The minimum value of the data type used in range partitions, useful as an argument to to.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
215 def maxvalue
216   MAXVALUE
217 end
minvalue()

The minimum value of the data type used in range partitions, useful as an argument to from.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
209 def minvalue
210   MINVALUE
211 end
modulus(v)

Assumes hash partitioning, sets the modulus for this partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
237 def modulus(v)
238   @modulus = v
239 end
partition_type()

Determine the appropriate partition type for this partition by which methods were called on it.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
269 def partition_type
270   raise Error, "Unable to determine partition type, multiple different partitioning methods called" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1
271 
272   if @from || @to
273     raise Error, "must call both from and to when creating a partition of a table if calling either" unless @from && @to
274     :range
275   elsif @in
276     :list
277   elsif @modulus || @remainder
278     raise Error, "must call both modulus and remainder when creating a partition of a table if calling either" unless @modulus && @remainder
279     :hash
280   elsif @default
281     :default
282   else
283     raise Error, "unable to determine partition type, no partitioning methods called"
284   end
285 end
range()

The from and to values of this partition for a range partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
253 def range
254   [@from, @to]
255 end
remainder(v)

Assumes hash partitioning, sets the remainder for this partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
242 def remainder(v)
243   @remainder = v
244 end
to(*v)

Assumes range partitioning, sets the exclusive maximum value of the range for this partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
227 def to(*v)
228   @to = v
229 end
values_in(*v)

Assumes list partitioning, sets the values to be included in this partition.

[show source]
    # File lib/sequel/adapters/shared/postgres.rb
232 def values_in(*v)
233   @in = v
234 end