0

I have multiple databases in my project based on company we are giving new database for that company.i am developing automation workflows in my current project for that i was planned to implemented queue-jobs concept to achieve this one.

we are maintaining one more database which will contain all databases list (companies which are using them).i was little confused how to approach these kind of scenarios,either i have to maintain jobs table in my commonDatabase or if i have to create jobs table inside each database separately.

Note:- EVery time user tried to login he has to give company name(All requests we are sending in headers) that indicates database name.

My doubts are:-

  • i created jobs table in each database but it's not inserting records in particular database,instead of it's inserting in commonDatabase jobs table?

  • what is the best way to acheive this kind of scenario ?

  • if any user logged out the queue will run background or not ?

Dwight
  • 12,120
  • 6
  • 51
  • 64
Test Test
  • 79
  • 5

1 Answers1

1

The thing I understand from you question is that you want to covert your project to multi-tenant multi-database and every company will generate a request to build tenant for them. The answers of your question are following:

I created jobs table in each database but it's not inserting records in particular database,instead of it's inserting in commonDatabase jobs table?

I must said you to watch this youtube play list. If the Job is related to a company process i.e. you want to process any company invoice email then you will dispatch job in company database and if job is related to commonDatabase i.e. you want to configure any company database then run migrations & seeder into it, then it should be dispatch in commonDatabase.

if any user logged out the queue will run background or not?

yes, the queue will still run in background because the queue worker run on server and it doesn't have any concern with login session or any other authentication medium. You must need to read following articles/threads

  1. Official Laravel Doc on queue
  2. How to setup laravel queue worker
M-Khawar
  • 855
  • 5
  • 17