collectiveidea / audited

Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
MIT License
3.34k stars 645 forks source link

Problems with mariadb since 10.4.3 JSON validation #667

Closed chmich closed 1 year ago

chmich commented 1 year ago

Hi

on mariadb i had audit set up with type json (generate audited:install --audited-changes-column-type json) docs

i updated my mariadb and encoutered the error

ActiveRecord::StatementInvalid: Mysql2::Error: CONSTRAINT audited_changes failed for cnc_office_test.audits

Since 10.4.3 mariadb has a json validation mariadb docs

By checking my database i found that the content of audited_changes on staging server, there was a YAML:

---
number: dsf
din_norm: swegr

So, my quick fix, on the development machine was to reset all databases, changed at the migration «...install_audited.rb» the line to t.column :audited_changes, :text re ran all migrations and the error was gone.

Seems that audited is not writing json, but, just since the switch to the newer mariadb. (Previous, on the mysql DB it wrotes audited_changes as json.)

And seems just to change the column type from json to text, is leading audited, no longer to tell the db for checking for a json.