Sha256: e425ec2757be26e127422e367cedfc821ddf8d6c5561d458dd909233956fa967

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

class AddPayloadToDelayedJobs < ActiveRecord::Migration<%= migration_version %>
  def up
    case ENV['DATABASE']
    when 'postgresql'
      add_column :delayed_jobs, :payload, :jsonb, null: false, default: {}
      add_index :delayed_jobs, :payload, using: :gin
    when 'mysql'
      add_column :delayed_jobs, :payload, :json
    else
      add_column :delayed_jobs, :payload, :json, null: false, default: {}
    end
  end

  def down
    case ENV['DATABASE']
    when 'postgresql'
      remove_column :delayed_jobs, :payload, :jsonb, null: false, default: {}
    when 'mysql'
      remove_column :delayed_jobs, :payload, :json
    else
      remove_column :delayed_jobs, :payload, :json, null: false, default: {}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
delayed_job_json-1.0.1 lib/generators/delayed_job_json/templates/migration1.rb
delayed_job_json-1.0.0 lib/generators/delayed_job_json/templates/migration1.rb