website icon indicating copy to clipboard operation
website copied to clipboard

Document how to use UUID with Auth better

Open jwoertink opened this issue 5 years ago • 1 comments

If you generate Auth in your API app, you'll get an UserToken class that assumes you have a User model that uses Int64 for your primary key. If you decide to use UUID, you'll need to make a few changes.

  • Update migration to set primary key to UUID
  • Add default_columns macro to base_model with UUID primary key
  • Change return type on decode_user_id method in UserToken class to UUID
  • Change the return value from payload["user_id"].to_s.to_i64 to UUID.new(payload["user_id"].to_s)

I think this is all you need to do, but we should have a section somewhere on the site that documents this.

jwoertink avatar May 01 '20 21:05 jwoertink

Since this is a bit old, I wrote up a blog post on doing this step by step in case it's helpful: https://stephencodes.com/blog/switching-lucky-to-uuids/

stephendolan avatar Jul 03 '20 20:07 stephendolan