Ruby on Rails Friday, October 25, 2013

By default, a table on PostgreSQL does not register UUID...
It might work only for new tables you create, because to Postgres use UUID you need say it when creating the table... for existing ones, it might not happen because the table on PostgreSQL may not have been created with the option to use Uuids.



Atenciosamente,

Carlos Figueiredo


On Fri, Oct 25, 2013 at 11:17 AM, kingston jenorish.s <jenorishstar@gmail.com> wrote:
Hi all,

I am using rails 3.1 and ruby 1.9.3,Now i want to use uuid concept in
rails 3 for existing data

so i did like :-

create_table :posts, :id => false do |t|
  t.string :uuid, :limit => 36, :primary => true
end

ActiveRecord::Base.class_eval do

# old rails versions
set_primary_key 'uuid'

before_create :generate_uuid
def generate_uuid
self.id = UUIDTools::UUID.random_create.to_s
end
end


This is working for new data,now i want to migrate existing data with
relation.for uuid they are using datatype as string,in postgresql the
data type used for primary_key and foreign key is integer ,so if i am
trying to change foreign key integer to string it is throwing error.

Could you please tell me some example,how to do this.

kingston.s

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAC2JRvHk-%3D8MmUmny_ovKKVbEQD6%3D%2By3Bc5-MDssvcBNUYxCrA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANPOtXt4xeqr2Uq0wwZJwW%2BqMi4T7J9-ScSmZm%2BXv1Wpoky0zQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment