Sha256: c680bed8b90fd9832c3522fc321c8443536c5e8006250dd80dd8c5ab4892073b

Contents?: true

Size: 819 Bytes

Versions: 52

Compression:

Stored size: 819 Bytes

Contents

class MakeLocksExclusive < ActiveRecord::Migration[5.0]
  BATCH_SIZE = 2

  def up
    change_table :foreman_tasks_locks do |t|
      t.remove :exclusive
      t.remove :name
      t.remove_index :name => 'index_foreman_tasks_locks_on_resource_type_and_resource_id'
      t.index [:resource_type, :resource_id], :unique => true
    end
  end

  def down
    change_table :foreman_tasks_locks do |t|
      t.boolean :exclusive, index: true
      t.string :name, index: true
      t.remove_index :name => 'index_foreman_tasks_locks_on_resource_type_and_resource_id'
      t.index [:resource_type, :resource_id]
    end

    scope = ForemanTasks::Lock.where(:name => nil)
    while scope.limit(BATCH_SIZE).update_all(:name => 'lock') == BATCH_SIZE; end
    change_column_null(:foreman_tasks_locks, :name, false)
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
foreman-tasks-10.0.1 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-10.0.0 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.2.3 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.2.2 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.2.1 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.2.0 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.1.1 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.0.4 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.1.0 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.0.2 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.0.1 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-8.3.3 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-9.0.0 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-8.2.1 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-8.1.4 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-8.3.2 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-8.3.1 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-8.1.3 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-8.3.0 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb
foreman-tasks-8.2.0 db/migrate/20181206131627_make_locks_exclusive.foreman_tasks.rb