drfraker/snipe-migrations
Laravel package that provides ready-to-use migration files for Snipe-IT, helping you set up and manage its database schema in PHP applications. Streamlines installation, customization, and upgrades with maintainable migrations for Snipe-IT tables.
composer require <vendor>/<package> (the v1.4.0 tag is the first with an explicit illuminate/support: ^8.0 constraint — confirm composer why-not resolves cleanly on an L8 app before upgrading production).php artisan vendor:publish --provider="<Vendor>\<Package>\<Package>ServiceProvider". You typically want the --tag=seeders (and --tag=config) groups separately so you can re-publish seeders without clobbering config.php artisan migrate then seed: php artisan db:seed --class="Database\\Seeders\\<Package>Seeder".run() signature, so the generated files are where regressions show up. Second place to look is your app's composer.json — verify "Database\\Seeders\\": "database/seeders/" exists in autoload.psr-4.php artisan migrate --seed, then confirm row counts match the package's documented totals.Database\Seeders\DatabaseSeeder::run():
public function run(): void
{
$this->call([
\Database\Seeders\CountriesSeeder::class, // package-published
\Database\Seeders\RolesSeeder::class,
]);
}
In Laravel 8 $this->call() accepts class-strings; prefer ::class constants over raw string paths so refactors don't silently no-op.RefreshDatabase, call $this->seed(\Database\Seeders\CountriesSeeder::class) in setUp() rather than running full migrate --seed — it's far faster and isolates the lookup tables your assertions depend on.migrate --force in the same deploy step: php artisan migrate --force && php artisan db:seed --class="Database\\Seeders\\CountriesSeeder" --force. The --force flag is mandatory outside local.DB::transaction() or chunk inserts (array_chunk($rows, 500)) — the default seeder does one insert per row in older versions, which is a common timeout source.Schema::disableForeignKeyConstraints() / enableForeignKeyConstraints() in a try/finally.DatabaseSeeder when app()->environment(['local','staging','testing']), and rely on --class for production reference data.database/seeds to database/seeders, and the default class from Database\Seeder to Database\Seeders\DatabaseSeeder. If you upgraded an app rather than installing fresh, previously published seeders sitting in database/seeds will no longer autoload and --class will throw Target class [...] does not exist. Re-publish, or move the files and update the namespace.composer dump-autoload. Stale autoload_classmap.php is the #1 cause of "seeder works on my machine" bugs.run() signature. Laravel 8 seeders use public function run(): void; the return type is optional but the void return is expected — a seeder returning a value or using the old Seeder base from the wrong namespace will fatal.insert() rather than upsert()/updateOrInsert(). Re-running without migrate:fresh will duplicate rows or violate unique keys. Guard with a if (Model::count() > 0) return; check, or truncate first, depending on whether you need to pick up upstream data changes.db:seed swallows a lot; add -vvv and check storage/logs/laravel.log. If rows are missing but no error appears, suspect a Model::unguard() missing and a mass-assignment Guarded exception being caught upstream.class MyCountriesSeeder extends CountriesSeeder) and overriding run() when you need to add or filter rows — that keeps you able to re-publish on the next patch release without a merge conflict. If the package exposes a config array of tables/columns, set it in config/<package>.php rather than editing seeders.illuminate/* constraint is ^8.0 only or ^5.8|^6|^7|^8 — if the PR pinned it narrowly, an L7 app on a shared dependency will fail to resolve and you'll need to hold the previous tag.migrate:fresh --seed is safe for local resets, but never in a deploy script: it drops every table regardless of which seeder you scoped with --class.How can I help you explore Laravel packages today?