From 7fff6361c1ec35d0ff61d27fedab301671b37b3a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 9 Apr 2009 15:17:12 +0000 Subject: [PATCH] Use the inet type for IP addresses in postgres. --- db/migrate/018_create_acls.rb | 7 ++----- lib/migrate.rb | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/db/migrate/018_create_acls.rb b/db/migrate/018_create_acls.rb index c9fd1f3e7..5205b99b0 100644 --- a/db/migrate/018_create_acls.rb +++ b/db/migrate/018_create_acls.rb @@ -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 diff --git a/lib/migrate.rb b/lib/migrate.rb index bb8ffa6e8..d43982e8c 100644 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@ -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 -- 2.43.2