I have a table column containing IP addresses, datatype is varchar(255)
. I want to switch to inet
datatype now. Is there a way to convert existing addresses in IP column to inet
datatype? Tried:
ALTER TABLE request_logs ALTER COLUMN ip type inet USING ip::inet;
ALTER TABLE request_logs ALTER COLUMN ip type inet USING CAST(ip AS inet);
But no luck, getting:
PG::DatatypeMismatch: ERROR: default for column "sign_up_ip" cannot be cast automatically to type inet
All values are '127.0.0.1'
. Postgres version is 9.6.9.