Class: Sequel::Postgres::CreateTableGenerator

Inherits:
Schema::CreateTableGenerator show all
Defined in:
lib/sequel/adapters/shared/postgres.rb

Constant Summary

Constants inherited from Schema::CreateTableGenerator

Schema::CreateTableGenerator::GENERIC_TYPES

Instance Attribute Summary

Attributes inherited from Schema::CreateTableGenerator

#columns, #constraints, #indexes

Instance Method Summary collapse

Methods inherited from Schema::CreateTableGenerator

#Bignum, #Fixnum, add_type_method, #check, #column, #constraint, #dump_columns, #dump_constraints, #dump_indexes, #foreign_key, #full_text_index, #has_column?, #index, #initialize, #method_missing, #primary_key, #primary_key_name, #respond_to_missing?, #spatial_index, #unique

Constructor Details

This class inherits a constructor from Sequel::Schema::CreateTableGenerator

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sequel::Schema::CreateTableGenerator

Instance Method Details

#exclude(elements, opts = OPTS) ⇒ Object

Add an exclusion constraint when creating the table. Elements should be an array of 2 element arrays, with the first element being the column or expression the exclusion constraint is applied to, and the second element being the operator to use for the column/expression to check for exclusion:

exclude([[:col1, '&&'], [:col2, '=']])
# EXCLUDE USING gist (col1 WITH &&, col2 WITH =)

To use a custom operator class, you need to use Sequel.lit with the expression and operator class:

exclude([[Sequel.lit('col1 inet_ops'), '&&'], [:col2, '=']])
# EXCLUDE USING gist (col1 inet_ops WITH &&, col2 WITH =)

Options supported:

:name

Name the constraint with the given name (useful if you may need to drop the constraint later)

:using

Override the index_method for the exclusion constraint (defaults to gist).

:where

Create a partial exclusion constraint, which only affects a subset of table rows, value should be a filter expression.



132
133
134
# File 'lib/sequel/adapters/shared/postgres.rb', line 132

def exclude(elements, opts=OPTS)
  constraints << {:type => :exclude, :elements => elements}.merge!(opts)
end