Skip to content

UUIDv7 any better? #1698

@bensheldon

Description

@bensheldon

I've heard lots of chatter about the benefits of UUIDv7. If you want to try it for now, here's how to patch it in:

# config/initializers/good_job.rb
module ActiveJobUUIDv7
  def initialize(*args)
    super
    @job_id = SecureRandom.uuid_v7
  end
  ruby2_keywords(:initialize)
end

ActiveSupport.on_load(:active_job) do
  include ActiveJobUUIDv7
end

ActiveSupport.on_load(:good_job_execution) do
  before_create { self.id ||= SecureRandom.uuid_v7 }
end

ActiveSupport.on_load(:good_job_process) do
  before_create { self.id ||= SecureRandom.uuid_v7 }
end

ActiveSupport.on_load(:good_job_batch_record) do
  before_create { self.id ||= SecureRandom.uuid_v7 }
end

ActiveSupport.on_load(:good_job_setting) do
  before_create { self.id ||= SecureRandom.uuid_v7 }
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Inbox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions