I am willing to give up the common denominator in database
compatibility and dive into using some PostgreSQL specific types. In
particular, I need bigint (int8) id columns and ‘cidr’ data type.
I know I can fake it with a string, but I really want to be able to
use the cidr type’s features. We’re not talking about a small
database here; it will likely be huge.
I managed to get a schema created using this:
class CreateProbes < ActiveRecord::Migration
create_table :probes do |t|
t.column “target”, :cidr
t.string :status, :limit => 1, :default => ‘A’
which does SOME of it. However, db/schema.db contains:
ActiveRecord::Schema.define(:version => 20090121052017) do
create_table “probes”, :force => true do |t|
t.string “target”, :limit => nil
t.string “status”, :limit => 1
which is NOT what I wanted. This makes all my “rake test” tests fail.
I looked into part of activerecord, and man is it tricky. Trying to
get this to work means major changes all over the place from what I
can see. There aren’t any database-specific hooks in place to allow
adding custom types without a lot of monkey patching.
Has anyone already done all this work by chance?