website
website copied to clipboard
Document how to use UUID with Auth better
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_idmethod inUserTokenclass toUUID - Change the return value from
payload["user_id"].to_s.to_i64toUUID.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.
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/