{"action":"created","issue":{"url":"https://api.github.com/repos/airblade/paper_trail/issues/248","labels_url":"https://api.github.com/repos/airblade/paper_trail/issues/248/labels{/name}","comments_url":"https://api.github.com/repos/airblade/paper_trail/issues/248/comments","events_url":"https://api.github.com/repos/airblade/paper_trail/issues/248/events","html_url":"https://github.com/airblade/paper_trail/issues/248","id":17661768,"number":248,"title":"Big objects","user":{"login":"brodock","id":20575,"avatar_url":"https://avatars.githubusercontent.com/u/20575?v=3","gravatar_id":"","url":"https://api.github.com/users/brodock","html_url":"https://github.com/brodock","followers_url":"https://api.github.com/users/brodock/followers","following_url":"https://api.github.com/users/brodock/following{/other_user}","gists_url":"https://api.github.com/users/brodock/gists{/gist_id}","starred_url":"https://api.github.com/users/brodock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brodock/subscriptions","organizations_url":"https://api.github.com/users/brodock/orgs","repos_url":"https://api.github.com/users/brodock/repos","events_url":"https://api.github.com/users/brodock/events{/privacy}","received_events_url":"https://api.github.com/users/brodock/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2013-08-05T21:49:58Z","updated_at":"2015-06-22T23:01:32Z","closed_at":"2015-06-22T23:01:32Z","body":"currently migration is like the following:\r\n\r\n```ruby\r\nclass CreateVersions < ActiveRecord::Migration\r\n  def self.up\r\n    create_table :versions do |t|\r\n      t.string   :item_type, :null => false\r\n      t.integer  :item_id,   :null => false\r\n      t.string   :event,     :null => false\r\n      t.string   :whodunnit\r\n      t.text     :object\r\n      t.datetime :created_at\r\n    end\r\n    add_index :versions, [:item_type, :item_id]\r\n  end\r\n\r\n  def self.down\r\n    remove_index :versions, [:item_type, :item_id]\r\n    drop_table :versions\r\n  end\r\nend\r\n```\r\n\r\nThis approach is good enough for objects that serialized is smaller then 64kb (on mysql), as this is the maximum size \"TEXT\" can hold, according to http://www.electrictoolbox.com/maximum-length-mysql-text-field-types/\r\n\r\nI've searched on how to force ActiveRecord migration to create \"MEDIUMTEXT\" or \"LONGTEXT\". It seems that all you have to do is define a limit that is bigger enough.\r\n\r\nSee http://stackoverflow.com/questions/4443477/rails-3-migration-with-longtext for more information.\r\n\r\nI don't know what is the best default versions should have. It seems like a good idea to have a bigger size as default to prevent headaches from people who figure out late that they lost data because it wasn't saved (as the object was bigger then expected). Also worth noting that it increases only 2 bytes per entry according to: http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html#id733892\r\n\r\nThis might be the reason #245 happened."},"comment":{"url":"https://api.github.com/repos/airblade/paper_trail/issues/comments/114295485","html_url":"https://github.com/airblade/paper_trail/issues/248#issuecomment-114295485","issue_url":"https://api.github.com/repos/airblade/paper_trail/issues/248","id":114295485,"user":{"login":"jaredbeck","id":380809,"avatar_url":"https://avatars.githubusercontent.com/u/380809?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredbeck","html_url":"https://github.com/jaredbeck","followers_url":"https://api.github.com/users/jaredbeck/followers","following_url":"https://api.github.com/users/jaredbeck/following{/other_user}","gists_url":"https://api.github.com/users/jaredbeck/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredbeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredbeck/subscriptions","organizations_url":"https://api.github.com/users/jaredbeck/orgs","repos_url":"https://api.github.com/users/jaredbeck/repos","events_url":"https://api.github.com/users/jaredbeck/events{/privacy}","received_events_url":"https://api.github.com/users/jaredbeck/received_events","type":"User","site_admin":false},"created_at":"2015-06-22T23:01:32Z","updated_at":"2015-06-22T23:01:32Z","body":"Closing, conversation can continue at https://github.com/airblade/paper_trail/pull/551"}}