discourse/discourse — pull request #1088 by ComputerDruid (2013-06-25 04:49:32+00:00)
Title: Fix ipv6 addresses in the database

This series updates the remaining 2 tables which store ip addresses as integers (bigint). This datatype is problematic when trying to store a 128-bit IPv6 address. Most tables in discourse use the `inet` type, which supports both IPv4 and IPv6 addresses nicely. This series converts the "views" and the "topic_link_clicks" tables to use the `inet` type to store ip addresses.

As this is the first time I have ever written a db migration, extra eyes on it would be appreciated to make sure that what I am doing is reasonable, and will work even at scale.

I had a hard time getting the "views" migration to work because the table does not have a primary key, so updating the table entries is difficult. I ended up using `update_all` for each distinct ip address in the table, but I have no clue how much that will hurt on a real database.

I recommend reading the commit diffs separately per-commit, as I have tried to organize them into logical chunks. I am happy to make changes to improve this series, if anything here can be improved.