I'm trying to add a column that defaults to a generated UUID without the hyphens as a varchar(32). Currently this is what my migration has:
add_column :users, :uuid, :string, limit: 32, default: "REPLACE(uuid_generate_v4(), '-', '')"
But it seems to error out because it's just setting that as string text:
PG::StringDataRightTruncation: ERROR: value too long for type character varying(32)
I can't seem to find proper documentation on setting a default value to an sql statement, but that it might be simpler to do in Rails 5 (https://github.com/rails/rails/pull/20005)