簡體   English   中英

PostgreSQL模式和Delayed :: Job

[英]Postgresql schemas and Delayed::Job

我正在使用Postgresql模式設置多租戶Rails應用程序。

如何確定Delayed :: Job的數據庫搜索路徑?

這將工作:

initializers/dj_config.rb:

Delayed::Job.class_eval do
 connection.schema_search_path = ["#{current_tenant}", "public"].join(",")
end

...但是我需要一種方法來傳遞當前的租戶,這似乎很難,因為DJ工作者與設置“ current_tenant”的過程不同。 有任何想法嗎?

我遇到了類似的問題,最終使用設置current_tenant的perform方法創建了自定義作業類。 我只是將current_tenant傳遞給構造函數:

Delayed::Job.enqueue CustomJob.new(current_tenant)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM