end
end
-class MergeAclAddressAndMask < ActiveRecord::Migration
+class MergeAclAddressAndMask < ActiveRecord::Migration[4.2]
+ class Acl < ApplicationRecord
+ end
+
def up
Acl.find_each do |acl|
address = IPAddr.new(acl.address)
prefix = 0
while netmask != "0.0.0.0"
- netmask = netmask << 1
- prefix = prefix + 1
+ netmask <<= 1
+ prefix += 1
end
acl.address = "#{address.mask(prefix)}/#{prefix}"