Publish-only migrations
A package that publishes its migrations with a timestamp must not also auto-load them — doing both runs both copies and fails on a duplicate table, a bug that hit three of our packages. Two package-only expectations pin the publish-only policy against a service provider:
expect($providerClass)->toNotAutoLoadMigrations(?string $migrationsDir = null);
expect($providerClass)->toPublishMigrationsTimestamped(string $tag, int $count);it('publishes its migrations instead of auto-loading them', function (): void {
expect(PasskeysServiceProvider::class)->toNotAutoLoadMigrations();
expect(PasskeysServiceProvider::class)->toPublishMigrationsTimestamped('passkeys-migrations', 3);
});- toNotAutoLoadMigrations — the package’s migrations directory (resolved from the provider by reflection, or passed explicitly) must not be registered with the migrator.
- toPublishMigrationsTimestamped — the tag must publish exactly $count sources, each to a database_path('migrations/<Y_m_d_His>_<name>.php') destination.
Both only make sense against a package service provider, so they are package-only — an app has no provider to point them at. The provider must be registered in the test’s app through packageProviders(): toNotAutoLoadMigrations fails on a provider that never booted, since it could not have registered anything and would pass for free. Static mirrors: Assert::doesNotAutoLoadMigrations() and Assert::publishesMigrationsTimestamped().
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.