Use the inet type for IP addresses in postgres.

This commit is contained in:
Tom Hughes 2009-04-09 15:17:12 +00:00
parent 2e1414b229
commit 7fff6361c1
2 changed files with 5 additions and 6 deletions

View file

@ -2,16 +2,13 @@ class CreateAcls < ActiveRecord::Migration
def self.up
create_table "acls", myisam_table do |t|
t.column "id", :integer_pk, :null => false
t.column "address", :integer, :null => false
t.column "netmask", :integer, :null => false
t.column "address", :inet, :null => false
t.column "netmask", :inet, :null => false
t.column "k", :string, :null => false
t.column "v", :string
end
add_index "acls", ["k"], :name => "acls_k_idx"
change_column "acls", "address", :integer, :null => false, :unsigned => true
change_column "acls", "netmask", :integer, :null => false, :unsigned => true
end
def self.down

View file

@ -52,7 +52,8 @@ module ActiveRecord
types[:bigint_auto_64] = { :name => "bigint(64) DEFAULT NULL auto_increment" }
types[:bigint_auto_11] = { :name => "bigint(11) DEFAULT NULL auto_increment" }
types[:bigint_auto_20] = { :name => "bigint(20) DEFAULT NULL auto_increment" }
types[:four_byte_unsigned] = { :name=> "integer unsigned NOT NULL" }
types[:four_byte_unsigned] = { :name=> "integer unsigned" }
types[:inet] = { :name=> "integer unsigned" }
types
end
@ -114,6 +115,7 @@ module ActiveRecord
types[:bigint_auto_11] = { :name => "bigint" } #fixme: need autoincrement?
types[:bigint_auto_20] = { :name => "bigint" } #fixme: need autoincrement?
types[:four_byte_unsigned] = { :name => "bigint" } # meh
types[:inet] = { :name=> "inet" }
types
end