Class: CreateCommandRuns

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/ruby_cms/templates/db/migrate/20260525160000_create_command_runs.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/ruby_cms/templates/db/migrate/20260525160000_create_command_runs.rb', line 6

def change
  create_table :command_runs, if_not_exists: true do |t|
    t.string  :command_key,  null: false
    t.string  :status,       null: false, default: "ok"
    t.integer :duration_ms,  null: false, default: 0
    t.text    :output
    t.text    :error_message
    RubyCms::MigrationHelpers.json_column(t, :params_used, null: false, default: {})
    t.references :ran_by, foreign_key: { to_table: :users }, type: :bigint
    t.string :ran_by_label
    t.datetime :started_at, null: false
    t.timestamps
  end

  add_index :command_runs, :command_key, if_not_exists: true
  add_index :command_runs, :started_at, if_not_exists: true
  add_index :command_runs, %i[command_key started_at], if_not_exists: true
end