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 CreateYourTableThis command generates a new migration file in the database/migrations directory.
2. Running Migrations
php artisan migrateThis command use for exicting migration.
3. Rolling Back Migrations
php artisan migrate:rollbackIt is used for roll back migration.
4. Status of Migrations
php artisan migrate:statusThis command shows the status of each migration.
5. Reset and Re-run Migrations
php artisan migrate:resetThis command rolls back all database migrations, effectively resetting the database.
php artisan migrate:refreshThis 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 --seedThis command migrates the database and then runs the seeders.
7. Rollback and Re-run Specific Batch
php artisan migrate:rollback --step=1This command rolls back the last batch of migrations.
php artisan migrate:refresh --seed --step=1This command resets and re-runs the last batch of migrations, including seeding.
8. Create a New Migration and Model
php artisan make:model YourModel -mThis command generates a new Eloquent model along with a migration file.