laravel-migrate-fresh-table
Sometimes you need to rebuild a single table from scratch โ reset a corrupted pivot, reapply a changed schema during development, or re-provision one table per tenant โ without nuking everything else. This Laravel package does exactly that, safely. Like migrate:fresh, but scoped, foreign-key aware, multi-connection and multitenant-friendly.
- ๐ฏ Scoped โ drop & recreate one table or an ordered list, not the whole DB.
- ๐ Foreign-key aware โ inspects the live schema, reports every parent and child relationship with the rows that would be orphaned, and asks first.
- ๐ Cascade or data-only โ --with-related refreshes a table plus its whole dependent tree; --data-only empties the rows and keeps the schema.
- ๐งฉ Pluggable โ re-run a table's migration, rebuild from an explicit Blueprint, or register your own strategy.
- ๐ข Multi-connection / multitenant โ target one connection, iterate a list, or resolve tenant connections dynamically. PostgreSQL search_path aware.
- ๐งช Safe by default โ confirms before running in protected environments (configurable), plus --dry-run, --pretend, and a transaction so a failed run rolls back instead of half-dropping.
- ๐ช Hookable โ lifecycle events and global before/after callbacks.
composer require kerroldj/laravel-migrate-fresh-table