Module: Tablature::Statements

Defined in:
lib/tablature/statements.rb

Overview

Methods that are made available in migrations.

Instance Method Summary collapse

Instance Method Details

#create_list_partition(name, options) {|td| ... } ⇒ Object

Creates a partitioned table using the list partition method.

Parameters:

  • name (String, Symbol)

    The name of the partition.

  • options (Hash)

    The options to create the partition.

Yields:

  • (td)

    A TableDefinition object. This allows creating the table columns the same way as Rails’s create_table does.

Raises:

  • (ArgumentError)

See Also:



11
12
13
14
15
# File 'lib/tablature/statements.rb', line 11

def create_list_partition(name, options, &block)
  raise ArgumentError, 'partition_key must be defined' if options[:partition_key].nil?

  Tablature.database.create_list_partition(name, options, &block)
end

#create_list_partition_of(parent_table_name, options) ⇒ Object

Creates a partition of a parent by specifying the key values appearing in the partition.

Parameters:

  • parent_table_name (String, Symbol)

    The name of the parent table.

  • options (Hash)

    The options to create the partition.

Raises:

  • (ArgumentError)

See Also:



23
24
25
26
27
# File 'lib/tablature/statements.rb', line 23

def create_list_partition_of(parent_table_name, options)
  raise ArgumentError, 'values must be defined' if options[:values].nil?

  Tablature.database.create_list_partition_of(parent_table_name, options)
end

#create_range_partition(name, options) {|td| ... } ⇒ Object

Creates a partitioned table using the range partition method.

Parameters:

  • name (String, Symbol)

    The name of the partition.

  • options (Hash)

    The options to create the partition.

Yields:

  • (td)

    A TableDefinition object. This allows creating the table columns the same way as Rails’s create_table does.

Raises:

  • (ArgumentError)

See Also:



37
38
39
40
41
# File 'lib/tablature/statements.rb', line 37

def create_range_partition(name, options, &block)
  raise ArgumentError, 'partition_key must be defined' if options[:partition_key].nil?

  Tablature.database.create_range_partition(name, options, &block)
end

#create_range_partition_of(parent_table, options) ⇒ Object

Creates a partition of a parent by specifying the key values appearing in the partition.

Parameters:

  • parent_table_name (String, Symbol)

    The name of the parent table.

  • options (Hash)

    The options to create the partition.

See Also:



49
50
51
52
53
54
55
# File 'lib/tablature/statements.rb', line 49

def create_range_partition_of(parent_table, options)
  if options[:range_start].nil? || options[:range_end].nil?
    raise ArgumentError, 'range_start and range_end must be defined'
  end

  Tablature.database.create_range_partition_of(parent_table, options)
end