So I have a custom package which I am using in my project which has a lot of migrations. The package contains a lot of migrations and seeds.
In the service provider of the package, I load the migrations like so:
$this->loadMigrationsFrom(__DIR__ . '/database/migrations/');
When I run php artisan migrate:refresh
locally, it works like a charm and the migrations are run and the tables are installed in the DB. But when I do the same on my server, it says nothing to migrate which is confusing since the same config works in my homestead env and not my production env.
Has anyone else faced a similar problem or has any idea on how to resolve this?
Advertisement
Answer
Could it be that the placement is different on your server, or that the command is executed from another place? __DIR__
isn’t too reliable in the best of situations.
Try abstracting your code by changing the line to this:
$this->loadMigrationsFrom(base_path() . '/database/migrations/');
base_path()
and app_path()
are handy functions when dealing with specific file locations inside your Laravel code 🙂
EDIT: Ow and another possibility: your migrations haven’t been added to your git repository. Happens to me more often than I care to admit 😉