Sha256: 951e07f3b0a46fe8851297947d9f72bcf514f9014d2174d7dc2c23a9f5e71c6c

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

# rubocop:disable Rails/CreateTableWithTimestamps
class AddHostReports < ActiveRecord::Migration[6.0]
  def change
    create_table :host_reports do |t|
      # Host reference, b-tree index.
      t.integer "host_id", null: false

      # Smart proxy which processed and uploaded, no index.
      t.integer "proxy_id"

      # Explicit timestamp, replaces Rails timestamps, b-tree descending index.
      t.datetime "reported_at", null: false

      # Use StatusCalculator to store arbitrary amount of counters in this
      # bit array (e.g. info, debug, error, fatal messages). Each report
      # implementation decides how to use this bitfield. No index.
      t.bigint "status"

      # Report contents, usually in JSON format depending on implementation.
      # Text field is by default compressed and not searchable, use
      # ReportKeyword model for searching. Other formats like JSON/JSONB were
      # considered but this appears to be the fastest option. No index.
      t.text "body"

      # Report type "enum", integer is faster and smaller than varchar.
      # No index since cardinality is very low (1-3 effectively)
      t.integer "format", default: 0, null: false

      # Indices. Keep it at the bare minimum, this model should be optimized
      # for updates not for reads.
      t.index "host_id"
      t.index "reported_at", order: { reported_at: :desc }
    end
  end
end
# rubocop:enable Rails/CreateTableWithTimestamps

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_host_reports-1.0.2 db/migrate/20210112183526_add_host_reports.rb
foreman_host_reports-1.0.1 db/migrate/20210112183526_add_host_reports.rb
foreman_host_reports-1.0.0 db/migrate/20210112183526_add_host_reports.rb
foreman_host_reports-0.0.4 db/migrate/20210112183526_add_host_reports.rb
foreman_host_reports-0.0.3 db/migrate/20210112183526_add_host_reports.rb