PHPackages                             badrshs/laravel-data-jobs - 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. badrshs/laravel-data-jobs

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

badrshs/laravel-data-jobs
=========================

A Laravel package for managing and executing data migration jobs with tracking and priority support

v1.1.0(4mo ago)621[1 issues](https://github.com/badrshs/laravel-data-jobs/issues)MITPHPPHP ^8.1|^8.2|^8.3CI passing

Since Jan 2Pushed 4mo agoCompare

[ Source](https://github.com/badrshs/laravel-data-jobs)[ Packagist](https://packagist.org/packages/badrshs/laravel-data-jobs)[ Docs](https://github.com/badrshs/laravel-data-jobs)[ RSS](/packages/badrshs-laravel-data-jobs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

Laravel Data Jobs
=================

[](#laravel-data-jobs)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f63714759bc2846cb8cba39074ce1e78ffd1b3a5b060c90af221d3717667b218/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626164727368732f6c61726176656c2d646174612d6a6f62732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/badrshs/laravel-data-jobs)[![Total Downloads](https://camo.githubusercontent.com/482efa9ed50a9f886396f45547135b02d28617006084d032476fea59fb6015f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626164727368732f6c61726176656c2d646174612d6a6f62732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/badrshs/laravel-data-jobs)[![License](https://camo.githubusercontent.com/397ee41cd9fdbd451d425e704e925562f7f3359caf39b351badb865346db6591/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626164727368732f6c61726176656c2d646174612d6a6f62732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/badrshs/laravel-data-jobs)

A Laravel package for running one-time data migration and transformation jobs in a controlled way.

It lets you define Artisan commands as data jobs that run once by default, can be prioritized, and are fully tracked. This is useful for tasks like migrating data after schema changes or backfilling data for new features.

The package automatically discovers these jobs, runs them in priority order, and records their status as pending, running, completed, or failed in the database. A single Artisan command, data:run-jobs, handles executing all registered jobs safely and in order.

The Problem
-----------

[](#the-problem)

When working on Laravel applications, you often need to run one-time data migrations or transformations—tasks that don't fit into regular database migrations but still need to be executed in a controlled, trackable way. These might include:

- Migrating data between tables after a schema change
- Backfilling data for new features
- Transforming existing data to match new requirements
- Seeding production data based on business logic

Managing these tasks manually is error-prone and makes it difficult to track what has been executed across different environments.

The Solution
------------

[](#the-solution)

**Laravel Data Jobs** provides a simple, elegant solution by turning Artisan commands into trackable, priority-based data jobs. Simply add the `DataJobable` trait to your command, and the package handles:

- ✅ **Automatic Discovery** - No manual registration required
- ✅ **Execution Tracking** - Prevents duplicate runs and logs all activity
- ✅ **Priority Support** - Control the order of job execution
- ✅ **Status Management** - Track pending, running, completed, and failed jobs
- ✅ **Error Handling** - Graceful failure handling with detailed error logging

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

[](#installation)

Install the package via Composer:

```
composer require badrshs/laravel-data-jobs
```

Run the installation command:

```
php artisan data-jobs:install
```

This will:

- Publish the configuration file to `config/data-jobs.php`
- Run the migration to create the `data_jobs_log` table

Usage
-----

[](#usage)

### 1. Create a Data Job Command

[](#1-create-a-data-job-command)

Create a new Artisan command:

```
php artisan make:command MigrateUsersCommandExample
```

### 2. Add the DataJobable Trait

[](#2-add-the-datajobable-trait)

Add the `DataJobable` trait to your command and optionally customize priority:

```
