From c14b1e359f9845333cdea76e1407da451aab7b02 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Fri, 15 Dec 2023 09:16:16 +0000 Subject: [PATCH] Check que_jobs exists before queueing jobs --- features/fixtures/que/app/enqueue-job.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/features/fixtures/que/app/enqueue-job.rb b/features/fixtures/que/app/enqueue-job.rb index 0589274c..45eff66b 100644 --- a/features/fixtures/que/app/enqueue-job.rb +++ b/features/fixtures/que/app/enqueue-job.rb @@ -1,5 +1,19 @@ require_relative "setup-que" +query = <<-SQL +SELECT EXISTS ( + SELECT FROM pg_tables WHERE tablename = 'que_jobs' +) AS que_jobs_exists +SQL + +Timeout::timeout(10) do + loop do + break if $connection.exec(query)[0]["que_jobs_exists"] == "t" + + sleep 0.1 + end +end + case ARGV[0] when "unhandled" UnhandledJob.enqueue