Laravel provides several Artisan commands related to migrations that you can use in the command-line interface.
Here is a list of common Laravel migration commands:
1. Create a New Migration File
php artisan make:migration CreateYourTable
This command generates a new migration file in the database/migrations directory.
2. Running Migrations
php artisan migrate
This command use for exicting migration.
3. Rolling Back Migrations
php artisan migrate:rollback
It is used for roll back migration.
4. Status of Migrations
php artisan migrate:status
This command shows the status of each migration.
5. Reset and Re-run Migrations
php artisan migrate:reset
This command rolls back all database migrations, effectively resetting the database.
php artisan migrate:refresh
This command resets and re-runs all migrations. It is useful during development when you want to quickly rebuild the entire database.
6. Seed the Database
php artisan db:seed
This command runs the database seeders, populating the database with test data.
php artisan migrate --seed
This command migrates the database and then runs the seeders.
7. Rollback and Re-run Specific Batch
php artisan migrate:rollback --step=1
This command rolls back the last batch of migrations.
php artisan migrate:refresh --seed --step=1
This command resets and re-runs the last batch of migrations, including seeding.
8. Create a New Migration and Model
php artisan make:model YourModel -m
This command generates a new Eloquent model along with a migration file.