From 1765036e765abe4c87d5c2f77fda44a516d2c67f Mon Sep 17 00:00:00 2001 From: Ben Sheldon Date: Wed, 2 Mar 2022 18:25:16 -0800 Subject: [PATCH] Delegate `ActiveJobJob.table_name` to `Execution` and prevent it from being directly assignable --- lib/good_job/active_job_job.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/good_job/active_job_job.rb b/lib/good_job/active_job_job.rb index 0c7df9da3..c19528571 100644 --- a/lib/good_job/active_job_job.rb +++ b/lib/good_job/active_job_job.rb @@ -15,7 +15,14 @@ class ActiveJobJob < BaseRecord # Attached to a Job's Execution when the Job is discarded. DiscardJobError = Class.new(StandardError) - self.table_name = 'good_jobs' + class << self + delegate :table_name, to: Execution + + def table_name=(_value) + raise NotImplementedError, 'Assign GoodJob::Execution.table_name directly' + end + end + self.primary_key = 'active_job_id' self.advisory_lockable_column = 'active_job_id'