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