Module: ActiveRecord::ConnectionAdapters::SchemaStatements

Defined in:
lib/activerecord-postgres-postgis/active_record/connection_adapters/schema_statements.rb

Instance Method Summary collapse

Instance Method Details

#add_geometry_column(table_name, column_name, options = {}) ⇒ Object

Adds a spatial column to the table using the PostGIS “AddGeometryColumn()” function.

This method exists for backwards compatability with PostGIS 1.x.

Example:

add_geometry_column :roads, :geom, srid: 423, spatial_type: 'LINESTRING', dimension: 2

37
38
39
# File 'lib/activerecord-postgres-postgis/active_record/connection_adapters/schema_statements.rb', line 37

def add_geometry_column(table_name, column_name, options = {})
  execute "SELECT AddGeometryColumn('#{table_name}', '#{column_name}', #{options[:srid]}, '#{options[:spatial_type]}', #{options[:dimension]})"
end