Author - StudySection Post Views - 74 views
Laravel

How to generate Laravel Migration Using existing Database

Laravel Migrations are version control for the database allowing your team to define and share the application’s database schema definition. It is challenging to add columns manually to their local database schema after pulling in your changes from the source control. To solve this problem we use Migrations.

By using, Laravel migration can create tables in your database, without actually going to the database manager such as PHPMyAdmin or SQL lite or whatever your manager is.

Basically, migration is used to generate database Tables.

So a question arises in mind is its reverse is possible or not? Mean we can generate migration from an existing database?
Yes, We can generate migrations from an existing database.

To generate migration from the existing database you need to install a package
Xethron/migrations-generator

This package will Generate Laravel Migrations from an existing database, including indexes and foreign keys also.

By using composer you can install this package with this command

composer require --dev "xethron/migrations-generator"

In Laravel 5.5 the service providers will be automatically get registered.
To generate migrations, Run

- php artisan migrate:generate
This will generate migrations for all tables. You can also ignore tables with ignore argument like this -ignore=table1,table2,…table(n).

You can run php artisan help migrate:generate for a list of options.

If you have skills in PHP programming and you want to enhance your career in this field, a PHP certification from StudySection can help you reach your desired goals. Both beginner level and expert level PHP Certification Exams are offered by StudySection along with other programming certification exams.

Leave a Reply

Your email address will not be published. Required fields are marked *