Class: CreateTableJobs

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/workhorse/templates/create_table_jobs.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/workhorse/templates/create_table_jobs.rb', line 2

def change
  create_table :jobs, force: true do |t|
    t.string :state, null: false, default: 'waiting'
    t.string :queue, null: true
    t.binary :handler, null: false, limit: 4_294_967_295

    t.string :locked_by
    t.datetime :locked_at

    t.datetime :started_at

    t.datetime :succeeded_at
    t.datetime :failed_at
    t.text :last_error, limit: 4_294_967_295

    t.integer :priority, null: false
    t.datetime :perform_at, null: true

    t.string :description, null: true

    t.timestamps null: false
  end

  if oracle?
    add_index :jobs, :queue
    add_index :jobs, :state
  else
    add_index :jobs, :queue, length: 191
    add_index :jobs, :state, length: 191
  end
  add_index :jobs, :perform_at
end