Class: AddBatchesTaskProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/db/migrate/20220727101904_add_batches_task_processor.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/db/migrate/20220727101904_add_batches_task_processor.rb', line 4

def change
  create_table :batches_task_processors do |t|
    t.string :key
    t.string :state, default: :pending
    t.json :data, default: [] if support_json?
    t.text :data, limit: 999999 unless support_json?
    t.integer :qty_jobs, default: 10
    t.datetime :finished_at
    t.text :preload_job_items
    t.text :process_item, null: false
    t.string :queue_name, default: :default
    t.timestamps
  end

  create_table :batches_task_processor_items do |t|
    t.belongs_to :batches_task_processors, foreign_key: true, index: { name: 'index_batches_task_processors_parent_id' }
    t.string :key
    t.text :result, limit: 999999
    t.text :error_details
    t.timestamps
  end
end

#support_json?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/db/migrate/20220727101904_add_batches_task_processor.rb', line 27

def support_json?
  connector_name = ActiveRecord::Base.connection.adapter_name.downcase
  no_json = connector_name.include?('mysql') || connector_name.include?('sqlite')
  !no_json
end