I need to change an array of ids in postgres from being integers to being uuids. It's in a Rails app, and there are other parts to this, but I can't figure this out.
I could do it in ActiveRecord, but I can't figure out how to get the sql to do this.
add_column :templates, :uuids, :uuid, array: true
Template.find_each do |template|
new_ids = template.conversations.map do |conversation_id|
conversation = Conversation.find_by(id: conversation_id)
conversation.uuid
end
template.update_column(:uuids, new_ids)
end
remove_column :templates, :conversations
rename_column :templates, :uuids, :conversations
I would expect this to work, but it tells me that no column uuids exists on templates.
Template.reset_column_informationafter the column creation and before the data migration?