From 14de59dbdc66cbd688619fbefdcadf21cdc6b371 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/features/fixtures/que/app/enqueue-job.rb b/features/fixtures/que/app/enqueue-job.rb index 0589274c..f22ee005 100644 --- a/features/fixtures/que/app/enqueue-job.rb +++ b/features/fixtures/que/app/enqueue-job.rb @@ -1,5 +1,21 @@ 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 + puts "~*~ que_jobs exists? ~*~ ", $connection.exec(query)[0]["que_jobs_exists"] + + break if $connection.exec(query)[0]["que_jobs_exists"] == "t" + + sleep 0.1 + end +end + case ARGV[0] when "unhandled" UnhandledJob.enqueue