skip to Main Content

I’ve DB in phpmyadmin with many tables in it.
I want to auto generate those tables into seperate laravel migration files.
Does anyone know of such a possibility?

2

Answers


  1. This way your migrations table will be separated for each database.

    Use the --database parameter with the migrate command and store the migrations for each database in separate directories.

    You could have separate directories in app/database/migrations for each of your database (for example : db1 and db2) and store the appropriate migrations in each directory. Then you could run the migrations like this:

    artisan migrate --database="db1" --path="app/database/migrations/db1"
    artisan migrate --database="db2" --path="app/database/migrations/db2"
    

    If you want to go the extra mile and automate the process you could create your custom command that will run all the migrations at once. You can create the command like this:

    artisan command:make MigrateAllCommand --command=migrate:all
    

    You can check the Laravel Command Docs for more info.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search