basecamp / audits1984

Auditing tool for Rails console sessions
MIT License
358 stars 26 forks source link

When your auditor table uses UUIDs as Primary Key #47

Open colinbruce opened 1 year ago

colinbruce commented 1 year ago

I'm just recording this in case it helps someone else or, after reviewing, the team tell me a better way! 😄

We use GUIDs as primary key for all tables so my Auditor record primary key starts with:

035d675a-0aa8-...

When audit records are created, the auditor_id is set as:

id status session_id auditor_id
1 1 4 35
1 1 3 35
1 1 2 35
1 1 1 35

I rolled back the migration and changed the script to

t.references :auditor, null: false, type: :uuid

After re-migrating, the system successfully records my Auditor account with no, so far, further errors!

bpurinton commented 1 year ago

Bump. Thank you. That one had me stumped for awhile. Might be worth an add to the README.