Sha256: ff71a1bc859dc3d8089ac5bc2252a87950d4f4b879d01f87ac35a237eb3c1bdc

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

class CreateEffectiveLogging < ActiveRecord::Migration[4.2]
  def self.up
    create_table <%= @logs_table_name %> do |t|
      t.string        :status

      t.string        :user_type
      t.integer       :user_id

      t.string        :changes_to_type
      t.integer       :changes_to_id

      t.string        :associated_type
      t.integer       :associated_id
      t.string        :associated_to_s

      t.text          :message
      t.text          :details

      t.timestamps
    end

    add_index <%= @logs_table_name %>, :id, order: { id: :desc }
    add_index <%= @logs_table_name %>, :updated_at
    add_index <%= @logs_table_name %>, :user_id
    add_index <%= @logs_table_name %>, :status
    add_index <%= @logs_table_name %>, :associated_to_s
    add_index <%= @logs_table_name %>, [:associated_type, :associated_id]
    add_index <%= @logs_table_name %>, [:changes_to_type, :changes_to_id]

    enable_extension('pg_trgm')
    add_index <%= @logs_table_name %>, :message, using: :gin, opclass: :gin_trgm_ops
    add_index <%= @logs_table_name %>, :details, using: :gin, opclass: :gin_trgm_ops
  end

  def self.down
    drop_table <%= @logs_table_name %>
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
effective_logging-4.0.0 db/migrate/01_create_effective_logging.rb.erb
effective_logging-3.5.4 db/migrate/01_create_effective_logging.rb.erb
effective_logging-3.5.3 db/migrate/01_create_effective_logging.rb.erb
effective_logging-3.5.2 db/migrate/01_create_effective_logging.rb.erb
effective_logging-3.5.1 db/migrate/01_create_effective_logging.rb.erb
effective_logging-3.5.0 db/migrate/01_create_effective_logging.rb.erb