DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk3 min

Should Your Team Prune Laravel Migrations? What `schema:dump –prune` Changes

Laravel's schema:dump --prune can simplify old migration files, but teams need committed schema artifacts for the connections used by clean installs, tests, and CI.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

php artisan schema:dump --prune writes the current database structure to a SQL file under database/schema and prunes existing migration files. Laravel can then build a new database from that schema file before running later migrations. The workflow is useful only if the right schema files are committed and available for every database connection your team actually uses.

What does php artisan schema:dump --prune do?

Laravel creates a schema file in the application’s database/schema directory. Its filename corresponds to the database connection. With --prune, Laravel also removes the existing migration files represented by the dump. Future migrations are still kept as migration files.

As an Amazon Associate I earn from qualifying purchases.

When Laravel migrates a connection that has no migrations recorded, it loads that connection’s schema file first, then runs migrations that are not included in the dump. In effect, the dump provides a starting point for a clean database; it does not replace migrations created afterward. See the Laravel 10.x migration documentation for the documented workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do I commit the schema file?

Yes. Laravel’s migration documentation says to commit the schema file so new developers can quickly create the application’s initial database structure. Without the artifact in a fresh checkout, the documented clean-start workflow cannot use that dump.

Before pruning, confirm that the generated file is included in source control and that a clean database can be created from the committed version. Keep the migration files you need for changes made after the dump; pruning is not a reason to omit later migrations from version control.

Why are my tests failing after I prune migrations?

A common configuration mismatch to check is that tests use a different database connection from local development. Laravel’s documentation specifically recommends creating a schema dump for a separate testing connection, giving this example:

php artisan schema:dump --database=testing --prune

Make an inventory of the connections used by developers, automated tests, and CI, then ensure each connection that needs a clean-start schema has its corresponding dump committed. A dump for the default connection does not, by itself, establish that a distinct test connection can be initialized.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should the team verify before pruning?

  • Clean-install reproducibility: Can a teammate or CI job create the initial database from the committed schema file and apply subsequent migrations?
  • Every connection: Are development, testing, and CI configured with the same connection names and schema artifacts expected by the application?
  • Driver and client availability: Laravel 10.x documents migration squashing for MySQL, PostgreSQL, and SQLite and says it uses the database’s command-line client. Check the documentation and tooling requirements for the Laravel version actually installed; do not assume the Laravel 10 list applies to every release.
  • Historical context: Do developers or maintainers rely on old migration files to understand how the schema evolved? A schema dump captures the current structure, not the sequence of decisions that produced it.
  • Deployment coordination: If several servers may run migrations during deployment, Laravel 10.x documents migrate --isolated, which uses a cache-backed atomic lock. The servers must use a shared central cache. This is a migration execution safeguard, not evidence that schema dumping itself is unsafe.

Does schema dumping work with multiple databases?

Schema files are associated with database connections, so treat each connection as its own setup to verify rather than assuming one dump covers every database. A Laravel Framework issue reports a problem in a particular two-database configuration: Laravel 8.69.0, PHP 8.0.10, and MySQL 5.7, with a secondary database that lacked its own migrations table. The issue page is closed but does not explain the resolution, so it does not establish a defect in current Laravel releases. See Laravel Framework issue #39476 and test the behavior against your installed version and connection configuration.

What if PostgreSQL uses transaction pooling?

Laravel 13’s database documentation describes configuring a direct PostgreSQL connection for migrations, schema dumps, and restores when transaction pooling is in use. If the pooled endpoint cannot perform those operations, verify that the direct connection details and credentials are configured and reachable in the environment that runs them. This guidance is version-specific; consult the documentation for your Laravel release. See Laravel 13 database documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Should your team prune its old migrations?

Pruning is a maintainability choice, not a universal upgrade or performance requirement. It fits best when the team can reliably create clean databases from committed schema dumps, including for separate test connections, and does not need the full migration sequence as its working record. Keeping the files may be preferable when migration history is important for explaining schema changes or when the team cannot yet verify its drivers, command-line clients, database connections, and deployment setup.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.