Skip to content

Commit 5352b72

Browse files
committed
Avoid a boot-time dependency on the database
Some environments (e.g., test) may not create the database, and so we should check that the table exists (which uses the schema cache) to skip the column lookup and the pending-migration warning.
1 parent 68832e2 commit 5352b72

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

app/models/solid_queue/claimed_execution.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
class SolidQueue::ClaimedExecution < SolidQueue::Execution
44
def self.process_name_column_exists?
5-
column_names.include?("process_name")
5+
table_exists? && column_names.include?("process_name")
66
end
77

88
if process_name_column_exists?
99
belongs_to :process, primary_key: :name, foreign_key: :process_name
1010
else
11-
warn_about_pending_migrations
11+
warn_about_pending_migrations if table_exists?
1212

1313
belongs_to :process
1414
attr_accessor :process_name

app/models/solid_queue/process/executor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Executor
99
if ClaimedExecution.process_name_column_exists?
1010
has_many :claimed_executions, primary_key: :name, foreign_key: :process_name
1111
else
12-
warn_about_pending_migrations
12+
warn_about_pending_migrations if ClaimedExecution.table_exists?
1313

1414
has_many :claimed_executions
1515
end

0 commit comments

Comments
 (0)