Looking to hire Laravel developers? Try LaraJobs

laravel-migration-extensions maintained by theupriser

Description
Laravel migration extensions
Author
Last update
2026/04/04 22:18 (dev-main)
License
Downloads
162

Comments
comments powered by Disqus

Very short description of the package

This package contains a couple of extensions for the laravel migrator.

Installation

You can install the package via composer with the following steps:

Install the theupriser/laravel-migration-extensions package.

composer require theupriser/laravel-migration-extensions

Usage

Conditional

The Conditional Interface makes it possible to run migrations based on conditions in your application. Sometimes you don't need tables or columns if your application doesn't need them.

How to

  1. Implement Conditional interface in your Seeder class.
return new class extends Migration implements Conditional 
  1. Add seeders from method stub, add seeders you want to run to the array
public function condition(): bool
{
    return true; // or return false if you don't want it to run.
}
  1. Run php artisan migrate

Seedable

The Seedable Interface makes it possible to run seeders after the migration runs. Every unique seed added will be executed once after the migrations have run. This function exists because Tables can change and so do the columns in your tables. If seeders are added to an earlier migration they break and have to be deleted from the migrations to be runnable again. You constantly have to keep track.

This changes that! you add the seeders to the seeders method in the Seedable class and the migrator will keep track for you. It even checks if the Seeder still exists in your project.

How to

  1. Implement Seedable interface in your Seeder class.
return new class extends Migration implements Seedable 
  1. Add seeders from method stub, add seeders you want to run to the array
public function seeders(): array
{
    return [
        \Database\Seeders\DatabaseSeeder::class,
    ];
}
  1. Run php artisan migrate

Credits