Merge pull request #551 from airblade/fix_mysql_text_too_short
In MySQL, use longtext instead of text
This commit is contained in:
commit
30a9d18052
|
@ -65,6 +65,8 @@ If you depend on the `RSpec` or `Cucumber` helpers, you will need to [manually l
|
|||
to `PaperTrail::Serializers::YAML`.
|
||||
- Both `PaperTrail.config` and `PaperTrail.configure` are now identical, and will both return the `PaperTrail::Config`
|
||||
instance and also yield it if a block is provided.
|
||||
- [#248](https://github.com/airblade/paper_trail/issues/248) - The migrations
|
||||
created by the generator now use `longtext` instead of `text` in MySQL.
|
||||
|
||||
## 3.0.8
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
class AddObjectChangesToVersions < ActiveRecord::Migration
|
||||
|
||||
# The largest text column available in all supported RDBMS.
|
||||
# See `create_versions.rb` for details.
|
||||
TEXT_BYTES = 1_073_741_823
|
||||
|
||||
def change
|
||||
add_column :versions, :object_changes, :text
|
||||
add_column :versions, :object_changes, :text, limit: TEXT_BYTES
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
class CreateVersions < ActiveRecord::Migration
|
||||
|
||||
# The largest text column available in all supported RDBMS is
|
||||
# 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
|
||||
# so that MySQL will use `longtext` instead of `text`. Otherwise,
|
||||
# when serializing very large objects, `text` might not be big enough.
|
||||
TEXT_BYTES = 1_073_741_823
|
||||
|
||||
def change
|
||||
create_table :versions do |t|
|
||||
t.string :item_type, :null => false
|
||||
t.integer :item_id, :null => false
|
||||
t.string :event, :null => false
|
||||
t.string :whodunnit
|
||||
t.text :object
|
||||
t.text :object, :limit => TEXT_BYTES
|
||||
t.datetime :created_at
|
||||
end
|
||||
add_index :versions, [:item_type, :item_id]
|
||||
|
|
Loading…
Reference in New Issue