]> git.openstreetmap.org Git - rails.git/commitdiff
Use the inet type for IP addresses in postgres.
authorTom Hughes <tom@compton.nu>
Thu, 9 Apr 2009 15:17:12 +0000 (15:17 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 9 Apr 2009 15:17:12 +0000 (15:17 +0000)
db/migrate/018_create_acls.rb
lib/migrate.rb

index c9fd1f3e7f957d709762f98632ba6c00a2275a78..5205b99b0403feaab7c65ba199637b253014004b 100644 (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
index bb8ffa6e8f4a4d1507d1f2625fa9b51985d0b49f..d43982e8c9f45dc21e2573bb98403d4e49ec6824 100644 (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