-
-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run migrations on database created when tenant is created ? #100
Comments
This is working for me:
|
Thanks for you reply, That seems to be the same line than mine, except you used double quotes... |
I think it is the quotes, try it like mine. If I use your line in my code, I get the same error. |
@LemarinelNet seems to be a parameters problem. Try with: Artisan::call('tenants:artisan', [
"artisanCommand" => "migrate --database=tenant",
"--tenant" => $this->id,
]); |
Still the same error : My full class is :
Could it be that the Artisan is searching a "migrate" command in the current namespace App, but it only exists in the App\Console\Commands namespace ? |
I don't know why it happens, but can you try to execute the following code before your migrations? Application::starting(function ($artisan) {
$artisan->resolveCommands([
\Illuminate\Database\Console\Migrations\MigrateCommand::class,
]);
}); |
Hi, |
It says to your application how to resolve the migration command. I had a similar problem fixed using the suggested code. I think that your problem isn't package-dependent, sorry. |
Finaly solved it ! I removed the "Application::starting" part that you suggested, since it was making my code failing, and just the Artisan::call did the trick ! Thanks for your help anyway ;) |
Great! Thanks for your share |
@LemarinelNet Thanks for the tip on the whitelist, that solved my problem too. One question, when you added |
I'm having the same issue using Artisan call method inside the console. It looks like it has something todo with tinker itself.
|
@joselara are you calling the migration from tinker or with a console command? Please post your code. Thanks |
Hi @schiffty, et. al.. - did you ever resolve your question? I've landed here having the same issue. I've tried to add
to @masterix21 - my code is inside a job that is being triggered within tinker when creating a new tenant. |
Hi @michaelhume, if you can, please share your code in a testable GitHub repository: I'll take a look asap. |
Thanks @masterix21 - I'm digging into it a bit more and will certainly post either a solution or a testable repo. |
I was able to sort it all out. There were a number of small configuration issues but ultimately attempting to use a database queue driver in a multitenant setup and dispatching jobs on new models that don't yet have a database gets a bit hairy. Thanks! |
Hi @masterix21 - Just to add a bit to this as it is coming up again for me. I've posted a question over on laracasts as well, but wanted to mention here as I suspect this may be related to this issue. TLDR - I believe I don't think it's really a package issue because this works when not in tinker, but I'm just wondering if anyone else has run into this or has any insight into what might be happening here? I'd like to understand why the different behaviour inside tinker. [edit] laravel/tinker#136 Thanks! |
Hi
I'm struggling a bit with this !
I got my database created automatically when a tenant is created, with an Event listener on my Tenant model :
and I tried to add some call to the Artisan command from this function, so the table are migrated, but I get an error :
'There are no commands defined in the "migrate" namespace.'
Thanks for your help !
The text was updated successfully, but these errors were encountered: