multiple databases problem #52159
Unanswered
CharrafiMed
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Why does
--path
solve my migration issue but--database
does not?I'm working on a Laravel project with multiple databases and custom migration directories. I've encountered an issue where running migrations with the
--database
option doesn't behave as expected.Context:
I have separate migrations for different databases in custom directories.
When I run
php artisan migrate --database=analytics_db
, it tries to run all migrations, including those that belong to other databases, leading to errors like:What I Tried:
I tried using
php artisan migrate --database=analytics_db
, but it attempts to run migrations for all databases, not justanalytics_db
.Solution I Found after reading underlined code (doesn't mention in the docs ):
Running the migrations with the
--path
option works correctly and only runs the migrations for the specified path:notice: of all the migrations i specified the database connection using
Schema::connection('database_name')->
Why does specifying the --path option solve the problem, but using the --database option does not? Is there something I'm missing about how the --database option is supposed to work?
Beta Was this translation helpful? Give feedback.
All reactions