Hi. I'm using a migration to extract data from one table, to another. In
the process I also convert ip-adresses to integers, for insertion in the
new table.
Problem is that migrations doesn't seem to handle large numbers very
well. The conversion works fine from the script/console, but when
running it from migrations only very low IP-ranges "make it thru".
Integer-based IPs seem to be capped around 2150000000.
You are probably running into the limitation of the integer type of the
database. Try storing them as strings instead of integers and use the
model to generate integers from them when you need them. That is, have
db attributes :start_ip_intstring and :end_ip_intstring (say) and
virtual attributes :start_ip_integer and :end_ip_integer which do the
conversion.
Problem is that I'm performing math stuff on them to see if an IP-adress
is in the range in between:
Ip.find(:all, :conditions => ["start_ip_integer <= ? AND end_ip_integer
= ?", @request_ip, @request_ip])
So converting them one by one would be painfully slow i suppose?
Specially since I have about 1 million ranges
The problem seems to be corrected when I change the int column to bigint
in the MySQL table. However, I don't know if I can set it to bigint in
the migrations directly. Can I?