How to migrate package by command line



  • I have created migration but not understanding that how to migrate any migration for package.

    I have tried to run "php artisan migrate" command on root folder but my migration file exist on package folder not a root folder.

    Please tell me how can i solve this problem ?

    Thanks ,



  • Hi _developer_12.

    It will work. Just follow these simple steps:

    1. Create your migration file inside (yourpackage -> src -> Database -> Migrations)
    2. Now, go to your service provider class (yourpackage -> src -> Providers -> yourpackageServiceprovider.php)
    3. Inside the boot() function add this code:
      $this->loadMigrationsFrom(__DIR __ . '/../Database/Migrations');
      ps. -> (In the above code remove the space beteween DIR and __)
    4. Now run the command (composer dump-autoload).

    After that run php artisan migrate and it will migrate your tables.

    Feel free to revert back in any kind of confusion or query.
    Thanks


Log in to reply