13 class MergeAclAddressAndMask < ActiveRecord::Migration[4.2]
14 class Acl < ApplicationRecord
18 Acl.find_each do |acl|
19 address = IPAddr.new(acl.address)
20 netmask = IPAddr.new(acl.netmask)
23 while netmask != "0.0.0.0"
28 acl.address = "#{address.mask(prefix)}/#{prefix}"
32 remove_column :acls, :netmask
36 add_column :acls, :netmask, :inet
38 Acl.find_each do |acl|
39 address = IPAddr.new(acl.address)
41 acl.address = address.address
42 acl.netmask = address.netmask
46 change_column :acls, :netmask, :inet, :null => false