saucy/db/migrate/20241107142809_make_name_not_null.solid_queue.rb

18 lines
617 B
Ruby
Raw Permalink Normal View History

2024-11-07 14:49:13 +00:00
# This migration comes from solid_queue (originally 20240813160053)
class MakeNameNotNull < ActiveRecord::Migration[7.1]
def up
SolidQueue::Process.where(name: nil).find_each do |process|
process.name ||= [ process.kind.downcase, SecureRandom.hex(10) ].join("-")
process.save!
end
change_column :solid_queue_processes, :name, :string, null: false
add_index :solid_queue_processes, [ :name, :supervisor_id ], unique: true
end
def down
remove_index :solid_queue_processes, [ :name, :supervisor_id ]
change_column :solid_queue_processes, :name, :string, null: false
end
end