Sha256: d20fc2d1d6350d8dc8f5f7ddba6fd8c7bcf39db23eab87754fbc0b7e368dc2f9

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

class CreateEffectiveLogging < ActiveRecord::Migration[6.0]
  def change
    create_table :logs 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, :id, order: { id: :desc }
    add_index :logs, :updated_at
    add_index :logs, :user_id
    add_index :logs, :status
    add_index :logs, :associated_to_s
    add_index :logs, [:associated_type, :associated_id]
    add_index :logs, [:changes_to_type, :changes_to_id]

    enable_extension('pg_trgm')
    add_index :logs, :message, using: :gin, opclass: :gin_trgm_ops
    add_index :logs, :details, using: :gin, opclass: :gin_trgm_ops

    create_table :tracks do |t|
      t.string        :owner_type
      t.integer       :owner_id

      t.string        :user_type
      t.integer       :user_id

      t.string        :action
      t.string        :title
      t.text          :details

      t.timestamps
    end

    add_index :tracks, :owner_id
    add_index :tracks, :user_id
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
effective_logging-4.3.1 db/migrate/101_create_effective_logging.rb
effective_logging-4.3.0 db/migrate/101_create_effective_logging.rb