13 class MergeAclAddressAndMask < ActiveRecord::Migration
15 Acl.find_each do |acl|
16 address = IPAddr.new(acl.address)
17 netmask = IPAddr.new(acl.netmask)
20 while netmask != "0.0.0.0"
21 netmask = netmask << 1
25 acl.address = "#{address.mask(prefix)}/#{prefix}"
29 remove_column :acls, :netmask
33 add_column :acls, :netmask, :inet
35 Acl.find_each do |acl|
36 address = IPAddr.new(acl.address)
38 acl.address = address.address
39 acl.netmask = address.netmask
43 change_column :acls, :netmask, :inet, :null => false