Download the PHP package jeffersongoncalves/pest-plugin-database-migrations without Composer
On this page you can find all versions of the php package jeffersongoncalves/pest-plugin-database-migrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeffersongoncalves/pest-plugin-database-migrations
More information about jeffersongoncalves/pest-plugin-database-migrations
Files in jeffersongoncalves/pest-plugin-database-migrations
Package pest-plugin-database-migrations
Short Description Load a package's migrations in tests in the exact order declared by its spatie/laravel-package-tools ServiceProvider
License MIT
Homepage https://github.com/jeffersongoncalves/pest-plugin-database-migrations
Informations about the package pest-plugin-database-migrations
Pest Plugin Database Migrations
Load a Laravel package's migrations in your tests in the exact order declared by its
ServiceProvider. The provider's hasMigrations() list is the truth; the test suite just
reads it.
Packages built with spatie/laravel-package-tools
ship migrations without timestamps, usually as .php.stub, and declare the run order in the
provider:
Laravel's migrator ignores that order and sorts files by name. create_kb_article_versions_table
sorts before create_kb_articles_table (_ < s in ASCII), which sorts before
create_kb_categories_table it references. SQLite doesn't enforce foreign keys at
CREATE TABLE time, so the suite passes locally, then breaks on MySQL/PostgreSQL. The usual
fixes are all bad: copying stubs around in defineDatabaseMigrations(), or keeping a second,
hand-maintained list of migration names in TestCase that drifts every time the package gains
a migration. This package reads the list straight from the ServiceProvider, so there is
nothing to keep in sync.
Installation
You can install the package via composer:
Usage
Orchestra Testbench
Before / after
What it replaces:
It works the same for a package's own test suite and for an app or package testing against a
dependency installed in vendor/ — the provider class is all it needs.
Multiple packages
Providers are loaded in the order you pass them, so a package can be migrated after the one it depends on:
Without the trait
How it works
- Instantiates the provider and calls
configurePackage()to readmigrationFileNames— nothing is registered or booted. - Resolves each name to
database/migrations/{name}.php, falling back to{name}.php.stub, the same waylaravel-package-toolsdoes. - Copies them to
sys_get_temp_dir()/pest-plugin-database-migrations/<hash>/as0000_name.php,0001_name.php, … and hands that directory toloadMigrationsFrom(). Files are only rewritten when their content changes, so parallel test workers don't read half-written files, and leftovers from a previous order are removed.
A declared migration that can't be found throws a RuntimeException naming the migration
and the provider, instead of silently skipping it.
Known limitations
- Only
spatie/laravel-package-toolsproviders. The provider must extendSpatie\LaravelPackageTools\PackageServiceProviderand declare migrations withhasMigration()/hasMigrations(). discoversMigrations()is not supported. Discovered migrations have no declared order to read; load that directory withloadMigrationsFrom()directly.- Migration names in the
migrationstable get the numeric prefix (0001_create_kb_articles_table). Only relevant if a test asserts on those names.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security
If you discover any security related issues, please email the author instead of using the issue tracker.
Credits
- Jefferson Gonçalves
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of pest-plugin-database-migrations with dependencies
illuminate/support Version ^11.0|^12.0|^13.0
spatie/laravel-package-tools Version ^1.15