Laravel Migration & Seeder Tips (Specific File/Class)
1. Run a Specific Migration File
Tip:
Make sure the path starts from the base Laravel directory. Double-check the filename and timestamp.
2. Rollback a Specific Migration File
Note:
This works only for files migrated in the last batch; otherwise, it will not affect anything.
3. Refresh a Specific Migration File
This command:
-
Rolls back the specific migration
-
Then runs it again (refresh)
4. Run a Specific Seeder Class
Make sure:
-
The seeder class exists in
database/seeders/
-
The class name is correct and matches the filename
📝 Quick Summary Table
Command | Purpose |
---|---|
migrate --path=... | Run one specific migration file |
migrate:rollback --path=... | Rollback one specific migration file |
migrate:refresh --path=... | Rollback & re-run one migration |
db:seed --class=SeederClass | Run a specific seeder class |