Chore/paper trail migration to jsonb columns#592
Merged
Conversation
09b469f to
6c94c77
Compare
santostiago
approved these changes
May 1, 2026
| t.string "event", null: false | ||
| t.string "whodunnit" | ||
| t.text "object" | ||
| t.text "old_object" |
Contributor
There was a problem hiding this comment.
This was a text field? 🤯
| puts "Wrote tmp/data_migrations_report_mission_type_report.csv" | ||
| end | ||
|
|
||
| desc "Move PaperTrail versions from YAML to JSON columns." |
Contributor
There was a problem hiding this comment.
Oh.. it was YAML. Then text field made sense.
| attrs = {} | ||
| attrs[:object] = PaperTrail::Serializers::YAML.load(version.old_object) if version.old_object.present? | ||
| attrs[:object_changes] = PaperTrail::Serializers::YAML.load(version.old_object_changes) if version.old_object_changes.present? | ||
| version.update_columns(attrs) if for_real |
Contributor
There was a problem hiding this comment.
Mmmm.. ok... but this just keeps the old data in a new field.
Shouldn't we also migrate the old data into JSON and start using that field everywhere?
Collaborator
Author
There was a problem hiding this comment.
YAML loading will load to hash, and that will be saved in new object and object_changes fields as JSON.
Collaborator
Author
There was a problem hiding this comment.
Then in the next PR, I will remove old fields.
6c94c77 to
7ef14d2
Compare
08b2034 to
af11062
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Paper trail migration to JSONB columns for better performance and less problems in the future.