PHPackages                             h3mantd/laravel-data-migrations-plus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. h3mantd/laravel-data-migrations-plus

ActiveLibrary[Database &amp; ORM](/categories/database)

h3mantd/laravel-data-migrations-plus
====================================

A migration-like system for versioned application data changes in Laravel

v1.0.4(1mo ago)1207[1 PRs](https://github.com/h3mantD/laravel-data-migrations-plus/pulls)MITPHPPHP ^8.3CI passing

Since Apr 4Pushed 2w agoCompare

[ Source](https://github.com/h3mantD/laravel-data-migrations-plus)[ Packagist](https://packagist.org/packages/h3mantd/laravel-data-migrations-plus)[ Docs](https://github.com/h3mantd/laravel-data-migrations-plus)[ GitHub Sponsors](https://github.com/h3mantd)[ RSS](/packages/h3mantd-laravel-data-migrations-plus/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (32)Versions (7)Used By (0)

Laravel Data Migrations Plus
============================

[](#laravel-data-migrations-plus)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2ff2fbbfb548a16809bd055017feb461dc404d27f2d36546fef357b4737927b7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68336d616e74642f6c61726176656c2d646174612d6d6967726174696f6e732d706c75732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/h3mantd/laravel-data-migrations-plus)[![GitHub Tests Action Status](https://camo.githubusercontent.com/a1b826523c7eeb08ddb0801d20c4afe4c5ac3992706401066e657f23f2d05a3d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68336d616e74642f6c61726176656c2d646174612d6d6967726174696f6e732d706c75732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/h3mantd/laravel-data-migrations-plus/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4ee52b6766559e37b1d1a22d4a5a4f673e3ffcce5072becc53b3e79a63f00df0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68336d616e74642f6c61726176656c2d646174612d6d6967726174696f6e732d706c75732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/h3mantd/laravel-data-migrations-plus)

A simple, migration-like system for **versioned application data changes** in Laravel. Use it for backfills, reference data, default records, reconciliation patches, and other data changes that should run once and be tracked.

The default path is intentionally small: create a data migration, write `up()`, run `data-migrate`. Advanced production features such as tenancy, checksums, rollback, and verification are available when you need them.

Table of Contents
-----------------

[](#table-of-contents)

- [Why Data Migrations](#why-data-migrations)
- [Requirements](#requirements)
- [Installation](#installation)
- [Simple Usage](#simple-usage)
    - [Create a Data Migration](#create-a-data-migration)
    - [Write the Data Change](#write-the-data-change)
    - [Central vs Tenant/Domain Migrations](#central-vs-tenantdomain-migrations)
    - [Run Data Migrations](#run-data-migrations)
    - [Check Status](#check-status)
    - [Query Builder and Optional Helpers](#query-builder-and-optional-helpers)
- [Advanced Usage](#advanced-usage)
    - [Generator Options](#generator-options)
    - [Running Options](#running-options)
    - [Migration Scopes](#migration-scopes)
    - [Migration Types](#migration-types)
    - [Transactions](#transactions)
    - [Pre-flight Validation](#pre-flight-validation)
    - [Reversible Migrations](#reversible-migrations)
    - [Inspecting a Migration](#inspecting-a-migration)
    - [Rolling Back](#rolling-back)
    - [Integrity Verification](#integrity-verification)
    - [Multi-Tenancy](#multi-tenancy)
    - [JSON Output and CI](#json-output-and-ci)
- [Reference](#reference)
    - [Directory Structure](#directory-structure)
    - [Configuration](#configuration)
    - [The Context Object](#the-context-object)
    - [Tracking Table](#tracking-table)
    - [Database Compatibility](#database-compatibility)
    - [Safe Patterns and Anti-Patterns](#safe-patterns-and-anti-patterns)
- [Testing](#testing)
- [License](#license)

Why Data Migrations
-------------------

[](#why-data-migrations)

Laravel schema migrations are excellent for changing database structure. Long-running applications also need a structured way to evolve application data across releases.

Common examples:

- Adding default roles, permissions, feature flags, or system records
- Backfilling new columns from existing data
- Normalizing lookup values after a schema change
- Fixing historical data after a bug
- Seeding required data in tenant databases
- Cleaning up deprecated records after a feature is removed

Seeders are usually not the right fit for this. They are designed for development and demo data. They are not append-only, not tracked like migrations, and can be accidentally re-run. This package gives data changes a migration-like lifecycle: versioned, tracked, append-only, and safe to run during deployments.

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11, 12, or 13
- Any database supported by Laravel: MySQL, PostgreSQL, SQLite, SQL Server, Oracle via [yajra/laravel-oci8](https://github.com/yajra/laravel-oci8), or another Laravel-compatible driver

Installation
------------

[](#installation)

Install the package with Composer:

```
composer require h3mantd/laravel-data-migrations-plus
```

Publish and run the tracking table migration:

```
php artisan vendor:publish --tag="data-migrations-migrations"
php artisan migrate
```

For single-database applications, that is enough to start using the package.

Publish the config only when you want to customize paths, the tracking table name, checksum behavior, locking, or tenant support:

```
php artisan vendor:publish --tag="data-migrations-config"
```

If you need to change the tracking table name or tracking connection, publish and edit the config before running `php artisan migrate`.

Simple Usage
------------

[](#simple-usage)

This is the full flow for most single-database Laravel applications.

### Create a Data Migration

[](#create-a-data-migration)

```
php artisan make:data-migration AddDefaultRoles
```

This creates a timestamped file in `database/data-migrations/`.

### Write the Data Change

[](#write-the-data-change)

A data migration is a PHP file that returns an anonymous class extending `DataMigration`. The only required method is `up()`.

```
