Add UUID Primary Key in Rails and MySQL -


i have table without id. know it's wrong design, want add primary key id table. here's script:

def   add_column :players, :id, :primary_key, first: true    change_table :players |t|     t.change :id, :uuid   end end  def down   remove_column :players, :id end 

the thing script generate integer value uuid column. how add primary key uuid table?

edit: it's in production. i can add id column, filled integer, not uuid expected.

in database environment, table column id primary key unique identifier of each row of table. it's integer value autoincrement (but not necessary) , 32bit or 64bit integer used. there no 2 rows in table same id.

in rails, uuid global unique identifier. can used identify user, session, anything. , id categories same. it's created random generator, reduce chance of having same uuid 2 different creations it's 128bit value.

there ways use uuid primary key, it's bad design idea since database engine has lookup rows based on , since it's big work find rows might harder. db have translation of uuids internal table row id.

i'm guessing need both primary key , separate uuid column, depends on context.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -