There are times when we will manually edit our table structure in our database for urgent reasons. We will then want to incorporate it into our migration files to migrate it later, while deploying on a live server.
To achieve this, we have to install a Laravel package called Laravel-migration-generator
.
Run the below command to install the package:
composer require --dev bennett-treptow/laravel-migration-generator
You also run the below command to publish the config files we will be using.
php artisan vendor:publish --provider="LaravelMigrationGenerator\LaravelMigrationGeneratorProvider"
composer require --dev bennett-treptow/laravel-migration-generator
Add the following to your bootstrap/app.php
file to register in the service provider.
$app->register(\LaravelMigrationGenerator\LaravelMigrationGeneratorProvider::class);
To generate the migration file of your database, you run the below command:
php artisan generate:migrations
By default, the file will go to tests/database/migrations
to specify the path using the command:
php artisan generate:migrations --path=database/migrations
Where the database/migrations
represents the path of your choice.