Search by

mshkop / laravel-data-migrations

mshkop

Data migrations for Laravel, kept apart from schema migrations (own table, folder and artisan commands). Maintained fork of jlorente/laravel-data-migrations.

Package info

github.com/mshkop/laravel-data-migrations

pkg:composer/mshkop/laravel-data-migrations

Statistics

Installs: 76

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v3.0.0 2026-12-02 12:37 UTC

This package is auto-updated.

Last update: 2026-12-02 12:40:18 UTC


README

Data migrations for Laravel, kept apart from schema migrations: their own folder (database/migrations_data), their own table and their own artisan commands. Use them for one-off data changes (backfills, settings, permissions, seed-like updates) that must run once per environment, in order, on deploy.

Maintained fork of jlorente/laravel-data-migrations (MIT, by José Lorente), updated for Laravel 12 and 13.

Requirements

  • PHP 8.2+
  • Laravel 12 or 13

Installation

composer require mshkop/laravel-data-migrations

The service provider is auto-discovered. Publish the config and the migrations folder:

php artisan vendor:publish --tag=data-migrations

Configuration

config/data-migrations.php:

return [
    // table of the executed data migrations - never the same as the schema "migrations" table
    'table' => 'migrations_data',
];

Usage

Command What it does
php artisan make:data-migration <name> create a data migration in database/migrations_data
php artisan migrate-data run the pending data migrations
php artisan migrate-data:rollback roll back the last batch
php artisan migrate-data:install create the data migrations table (done automatically by migrate-data)

A data migration is a normal Laravel migration class:

use App\Models\Setting;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
    public function up(): void
    {
        Setting::query()->updateOrCreate(['key' => 'feature.enabled'], ['value' => true]);
    }

    public function down(): void
    {
        Setting::query()->where('key', 'feature.enabled')->delete();
    }
};

The commands take every option of their framework counterparts (migrate, migrate:rollback, migrate:install, make:migration) of the installed Laravel version: --force, --pretend, --step, --database, --path, --graceful, ... A --path is relative to the project root.

Typical deploy order: php artisan migrate --force then php artisan migrate-data --force.

Migrating from jlorente/laravel-data-migrations

  1. composer remove jlorente/laravel-data-migrations && composer require mshkop/laravel-data-migrations
  2. Replace references to the Jlorente\DataMigrations\ namespace, if you have any (an explicitly registered service provider, subclasses of its commands).
  3. Keep your config/data-migrations.php: the table, the folder and the command names are the same, so the already executed data migrations are not run again.

Changes compared to jlorente/laravel-data-migrations 2.0.2

  • Laravel 13 support. The original commands hardcoded copies of the framework command signatures, so migrate-data failed with The "schema-only" option does not exist, and migrate-data:install registered itself as migrate:install, replacing the schema command. The commands now derive their definition from the installed framework command and only change the name.
  • migrate-data no longer tries to load a schema dump.
  • Config defaults are merged, so the published config file is optional.
  • Tests (Orchestra Testbench) and CI.

Testing

composer install
composer test

License

MIT - see LICENSE.txt.