
Get Started
Welcome to the documentation for the Laravel Migration Enhancement Package. This Composer package is designed to simplify and enhance the migration process in Laravel, providing developers with more efficient tools for managing database schema changes.
Installation
$ composer require helloarman/dumptable
$ php artisan storage:link
Requirement
Options | Version |
---|---|
PHP | v8.0+ |
Laravel | v7+ |
Features
Here are all of the feature list of the package.
Update Table with Dumptable Command:
Command:
$ php artisan table:dump {table_name}
Description:
This command updates a table with its corresponding migration file. It is particularly useful during the development phase when you need to update a specific column in a single table without affecting other tables. Unlike php artisan migrate:fresh or php artisan migrate:refresh, this command only affects the specified table.
Alternatively, you can use
php artisan migrate:dump-table {table_name}
to
execute this command.
Flags:
Flag | Workings |
---|---|
-s or --seed | Migrate and run the seeder file after updating the migration file. |
-r or --restore | Update the columns without removing existing data from the table. |
Command:
$ php artisan table:dump {table_name} --restore
This --restore or -r feature is in beta. Currently, it cannot handle a large amount of data (I tested with 20,000+ entries, and it worked perfectly). Additionally, if this table is used as a foreign key in another table, it may fail. However, don't worry, a backup file will be saved in the storage folder if it fails. Use this feature only during development.
Command:
$ php artisan table:dump {table_name} --seed
By default, --seed or -s it uses the
ModelNameSeeder
class name structure. To use a
different seeder file name, use the --class
flag.
Flags:
Flag | Workings |
---|---|
--class | To use a different seeder file name |
Command:
$ php artisan table:dump {table_name} --seed --class={seeder_class_name}
Backup Table Data:
Command:
$ php artisan table:backup {table_name}
Description:
This command creates a backup SQL file of the specified table in the storage/backups folder.
Restore Table Data:
Command:
$ php artisan table:restore {table_name}
Description:
This command restores the SQL file data to the specified table.
Flags:
Flag | Workings |
---|---|
-d or --delete | Delete the SQL file after restoring the data. |
Command:
$ php artisan table:restore {table_name} --delete
Fresh and Seed Data:
Command:
$ php artisan table:fresh-seed {table_name}
Description:
This command seeds data into the specified table, deleting previous data. It is useful for resetting table data during development.
By default, it uses the ModelNameSeeder
class name
structure. To use a different seeder file name, use the
--class
flag.
Flags:
Flag | Workings |
---|---|
--class | To use a different seeder file name |
Command:
$ php artisan table:fresh-seed {table_name} --class={seeder_class_name}
Align Additional Migration File:
Command:
$ php artisan table:col {type} {column_name} {table}
Description:
This command simplifies the process of updating a migration file in a production environment. Instead of creating a new migration file with the current date, it aligns the new file immediately after the main migration file for the table. This makes it easier to find and manage migration files, keeping the structure well-organized.
Screenshot:

Command and Output File Naming Examples:
Command | Migration File Name |
---|---|
$ php artisan table:col add type services
|
2023_04_28_205611_add_type_to_users_table.php
|
$ php artisan table:col update type services
|
2023_04_28_205612_update_type_to_users_table.php
|
$ php artisan table:col remove short_description
services
|
2023_04_28_205613_remove_short_description_to_users_table.php
|
and so on...
|
Command:
$ php artisan table:fresh-seed {table_name} --class={seeder_class_name}
FAQ:
Error Handling:
# After running dump:table {table_name} --restore:
As restore flag is in beta version. so there are some limitations. We are working on it. In-sha-Allah we will resolve it.
If your data was not restored, there may be an issue. If you
encounter such an issue, you have a backup file available in
the storage. Backup File:
C:\laragon\www\confirm-cart\storage\backups/services.sql
Solution:
This is not actually an issue. It is just a warning that if your data was not restored. Please check backup file for that.
Main reason for not restoring data:
- Storage file is not linked properly. run command
php artisan storage:link
- Having foreign keys in your table
- adding new row without adding nullable() values