rails migration: postgresql for md5 of random string as default
Rails 3 + postgresql I want to have a sha of a random string for a default value of a column. So, in my migration I have: t.string :uniqueid, default: md5(random()::text) However i can not get this to actually produce anything, I've used backticks, quotes,etc. From examples that I've seen it seems like that pg function only works in a SELECT statement. Is that accurate? Any ideas on how I could achieve this? Thanks mu is too short Rails will try to interpret this: t.string :uniqueid, default: md5(random()::text) as Ruby code and :default => md5(...) doesn't mean anything in Ruby. If you quote