Sha256: 56edb890a5fcff41e4482a6eb71d9f2d29ebe07409b8235bc6688f725eef16db

Contents?: true

Size: 1.67 KB

Versions: 64

Compression:

Stored size: 1.67 KB

Contents

# This migration comes from dm_core (originally 20160128094739)
# Migration for upgrading PaperTrail from V3 to V4
#------------------------------------------------------------------------------
class UpdatePapertrailV4 < 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 up
    change_column :versions, :created_at,     :datetime, precision: 6
    change_column :versions, :object,         :text, limit: TEXT_BYTES
    change_column :versions, :object_changes, :text, limit: TEXT_BYTES
    add_column    :versions, :transaction_id, :integer
    add_index     :versions, [:transaction_id]

    create_table :version_associations do |t|
      t.integer  :version_id
      t.string   :foreign_key_name, :null => false
      t.integer  :foreign_key_id
    end
    add_index :version_associations, [:version_id]
    add_index :version_associations,
      [:foreign_key_name, :foreign_key_id],
      :name => 'index_version_associations_on_foreign_key'
  end

  def down
    change_column :versions, :created_at,     :datetime
    change_column :versions, :object,         :mediumtext
    change_column :versions, :object_changes, :mediumtext
    remove_index  :versions, [:transaction_id]
    remove_column :versions, :transaction_id

    remove_index :version_associations, [:version_id]
    remove_index :version_associations,
      :name => 'index_version_associations_on_foreign_key'
    drop_table :version_associations
  end
end

Version data entries

64 entries across 64 versions & 4 rubygems

Version Path
dm_newsletter-4.2.3.10 spec/dummy/db/migrate/20160128145240_update_papertrail_v4.dm_core.rb
dm_forum-4.2.3.10 spec/dummy/db/migrate/20160128144313_update_papertrail_v4.dm_core.rb
dm_event-4.2.3.10 spec/dummy/db/migrate/20160128154136_update_papertrail_v4.dm_core.rb
dm_cms-4.2.3.10 spec/dummy/db/migrate/20160128134523_update_papertrail_v4.dm_core.rb
dm_newsletter-4.2.3.9 spec/dummy/db/migrate/20160128145240_update_papertrail_v4.dm_core.rb
dm_forum-4.2.3.9 spec/dummy/db/migrate/20160128144313_update_papertrail_v4.dm_core.rb
dm_event-4.2.3.9 spec/dummy/db/migrate/20160128154136_update_papertrail_v4.dm_core.rb
dm_cms-4.2.3.9 spec/dummy/db/migrate/20160128134523_update_papertrail_v4.dm_core.rb
dm_newsletter-4.2.3.8 spec/dummy/db/migrate/20160128145240_update_papertrail_v4.dm_core.rb
dm_forum-4.2.3.8 spec/dummy/db/migrate/20160128144313_update_papertrail_v4.dm_core.rb
dm_event-4.2.3.8 spec/dummy/db/migrate/20160128154136_update_papertrail_v4.dm_core.rb
dm_cms-4.2.3.8 spec/dummy/db/migrate/20160128134523_update_papertrail_v4.dm_core.rb
dm_newsletter-4.2.3.7 spec/dummy/db/migrate/20160128145240_update_papertrail_v4.dm_core.rb
dm_forum-4.2.3.7 spec/dummy/db/migrate/20160128144313_update_papertrail_v4.dm_core.rb
dm_event-4.2.3.7 spec/dummy/db/migrate/20160128154136_update_papertrail_v4.dm_core.rb
dm_cms-4.2.3.7 spec/dummy/db/migrate/20160128134523_update_papertrail_v4.dm_core.rb
dm_newsletter-4.2.3.6 spec/dummy/db/migrate/20160128145240_update_papertrail_v4.dm_core.rb
dm_forum-4.2.3.6 spec/dummy/db/migrate/20160128144313_update_papertrail_v4.dm_core.rb
dm_event-4.2.3.6 spec/dummy/db/migrate/20160128154136_update_papertrail_v4.dm_core.rb
dm_cms-4.2.3.6 spec/dummy/db/migrate/20160128134523_update_papertrail_v4.dm_core.rb