laravelvoyager

How do I override laravel voyager migration files?


Currently I'm using laravel voyager in one of my laravel projects my issue is that voyager comes with some migration files out of the box these migration files sometimes causes conflicts with my own migration files especially that which creates the users table so how is it that i can modify voyager migration files checking the documentation only tells me how to override views and controllers but nothing about migration files. Can some provide the steps you would take to accomplish this task ?


Solution

  • You can publish them using artisan vendor:publish, then deleting/modifying the ones you need to.

    However, sometime the libraries doesn't allow you to publish all their files. I mounted a quick project and it seems to be the case for voyager. Apparently, you can only publish the dummy migrations. In that case, I can see only 3 possibles way:

    1. Fix the conflict on your side. It will be the easier and cleaner way.
    2. Copy manually the migrations vendor/tcg/voyager/migrations to database/migrations and use php artisan migrate before php artisan voyager:install
    3. Fork the library and do your changes. Not the best, you will have to maintain your fork as well as your app.
    4. Copy manually the migrations vendor/tcg/voyager/migrations to database/migrations then extend/override vendor/tcg/voyager/src/VoyagerServiceProvider.php to force to not register the migrations. But I would'nt recommend, since event a minor update could break your app.

    Additional Warning with the points 2 3 and 4: If you do change e.g. a Voyager column name, the library may use the column name in the library and you may encounter some others problem. I do believe you should adapt your migrations and your codebase.