[Georuby-devel] SpatialAdapter Migrations: Providing an option to not use AddGeometryColumn?

Leo Soto M. leo.soto at gmail.com
Tue May 13 16:16:56 EDT 2008


I have been continuing integrating GeoRuby and the Spatial Adapter
into an pre-existing project (with a pre-existent database), and,
until now, it seems to work fine.

But now I want to run a migration to create a new table which will
include a geometry column. Even before using the Spatial Adapter, the
following worked:

t.add_column :foo, :geometry, :null => false

But, as ActiveRecord didn't recognized the datatype, passed it to the
database "as is". So I had to manually add a check constraint for the

Now that SpatialAdapter is installed, it reconizes :geometry, and adds
the ndimsconstraint automatically, as a result of using
AddGeometryColumn to create the foo column. Sadly, it also adds the
columns to geometry_columns and adds a srid constraint. I don't want
that, because this particular column won't have a fixed SRID.

I see the following options:

 1. Use raw SQL instead of add_column. Ugly, but should work.
 2. Use add_column and later raw SQL to delete the column from
geometry_columns and drop the srid constraint. Even ugliest.
 3. Hack SpatialAdapter to recognize this scenario.

What do you think about the third option?

Leo Soto M.

More information about the Georuby-devel mailing list