- What does jeffersongoncalves/pest-plugin-database-migrations do?
- It is a Pest PHP plugin that adds database migration helpers to Laravel test suites. Its main purpose is to load a package's migrations in tests in the exact order declared by its spatie/laravel-package-tools ServiceProvider. It also provides traits and expectations for running, refreshing, and rolling back migrations so tests stay isolated and schemas stay in sync.
- How do I install the Pest database migrations plugin?
- Install it as a Composer dependency in your Laravel project, typically as a dev dependency since it is test tooling. Use Composer to require jeffersongoncalves/pest-plugin-database-migrations, then make sure Pest is configured for your test suite. Check the package README for any required plugin registration or trait usage.
- How does it load a package's migrations in the correct order?
- It reads the migration order declared by the package's spatie/laravel-package-tools ServiceProvider. That means tests run the package migrations in the same sequence the package intends, rather than relying on filesystem order. This helps avoid foreign key and dependency issues when testing package schemas.
- Does it work with spatie/laravel-package-tools ServiceProviders?
- Yes. The package is specifically designed to respect the migration order declared by a spatie/laravel-package-tools ServiceProvider. You can use it when testing Laravel packages that register migrations through that tooling. It keeps the test migration order aligned with the package's declared order.
- Can I run, refresh, and roll back migrations between tests?
- Yes. The plugin adds migration helpers to your Pest test suite for running, refreshing, and rolling back migrations between tests. These helpers reduce boilerplate and help keep each test isolated with a predictable schema. You use them through the provided traits and expectations.
- Does this package replace Laravel's RefreshDatabase trait?
- The package provides its own migration helpers and traits for Pest tests; the provided context does not state that it replaces Laravel's RefreshDatabase trait. You can treat it as a focused helper for package migration ordering and migration lifecycle actions. Evaluate it alongside your existing database testing strategy and check the README for recommended usage.
- Can I test package migrations without publishing them to the host app?
- The package is built to load a package's migrations directly in tests, so you do not need to publish them into the host application just to exercise them. This is useful for package authors who want to verify migrations in isolation. It loads them in the order declared by the package's ServiceProvider.
- Which Laravel and Pest versions are supported?
- The package is a Pest plugin aimed at Laravel test suites, so you need a Pest-based Laravel testing setup. The exact Laravel and Pest version constraints are defined in the package's composer.json. Check those constraints before installing to confirm compatibility with your application.
- Is this package safe to use in production?
- No, it is test tooling intended for development and CI test suites, not production runtime. You should require it as a dev dependency and keep it out of production deployments. It helps with migration helpers and schema isolation during tests.
- What are alternatives to this plugin for Laravel package migration tests?
- Alternatives include Laravel's built-in database testing traits, manually calling Artisan migrate in tests, and package testing tools such as Orchestra Testbench. This plugin is specifically useful when you need Pest helpers and migration ordering from spatie/laravel-package-tools. Choose based on whether you need that exact ordering behavior and Pest integration.