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
34
35
|
# File 'lib/migrate.rb', line 2
def self.up
create_table :jobs do |t|
t.string :path
t.string :batch_id
t.text :args
t.text :result
t.datetime :started_at
t.datetime :cancelled_at
t.datetime :completed_at
t.string :status
t.integer :priority, :default => 1, :null => false
t.string :error_class
t.string :error_message
t.text :error_backtrace
t.string :employee_host
t.integer :employee_pid
t.timestamps
end
add_index :jobs, :path
add_index :jobs, :batch_id
add_index :jobs, :status
postgres = (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL')
['started_at', 'cancelled_at', 'completed_at'].each do |field|
execute "CREATE INDEX IF NOT EXISTS jobs_#{field}_is_null ON jobs (#{field})" + (postgres ? " WHERE #{field} IS NULL" : '')
end
end
|