Replies: 1 comment
-
you could use a scheduled console command to loop through each tenant, then in that code you could call a job which would have the TenantAware against it. that way each job would be tenant specific i.e execute the code against the correct tenant database.
Then write the console command as normal. If you run your job from within the console command, then you can queue up the TenantAware Job as normal. I had a similar problem with failed_jobs table, where it was going to the tenant database failed_jobs rather than the landlord failed_jobs table |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a scheduled queue job that runs daily for each of the tenants in my application. I am using Spatie's Multi Tenant package. I tried to use their tenant aware queues, but I was not able to loop over each tenant and set the current tenant. It seemed like it would only set the tenant to the last tenant.
I was curious if anybody knew of a way to run tenant defined queues on a schedule that obey the $tenant->makeCurrent(). Then, once the job was complete for that tenant, then it would make the next tenant the current tenant and then run the script in the queue.
Basically what I want is this scheduled clean up queue job to run for each tenant. I can get it to work if I set the queue job to not tenant aware and then manually set the tenant in the queue job. But, then when it fails, it will not write to the tenant database failed jobs table... it instead tries to write to the landlord database.
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions