PHPackages                             ebs/parents-one-time-operations - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. ebs/parents-one-time-operations

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

ebs/parents-one-time-operations
===============================

Run operations once after deployment - just like you do it with migrations!

v1.0.5(3y ago)012MITPHPPHP ^7.2

Since Mar 20Pushed 3y agoCompare

[ Source](https://github.com/BraileanuGabriel/parents-one-time-operations)[ Packagist](https://packagist.org/packages/ebs/parents-one-time-operations)[ Docs](https://github.com/timokoerber/laravel-one-time-operations)[ RSS](/packages/ebs-parents-one-time-operations/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

[![Laravel One-Time Operations](https://user-images.githubusercontent.com/65356688/224445279-9526bda2-ba1f-4add-8897-92fa80dd5973.jpg)](https://user-images.githubusercontent.com/65356688/224445279-9526bda2-ba1f-4add-8897-92fa80dd5973.jpg)

Laravel One-Time Operations
===========================

[](#laravel-one-time-operations)

Run operations once after deployment - just like you do it with migrations!

---

**Take your CI/CD to the next Level with Laravel One-Time Operations**! 🚀

Create specific classes for a one-time usage, that can be executed automatically after each deployment. Same as migrations they get processed once and then never again. Perfect for seeding or updating some data instantly after some database changes or feature updates.

This package is for you if...

- you regularly need to **update specific data** after you deployed new code
- you often execute jobs just **only one single time** after a deployment
- you sometimes **forget to execute** that one specific job and stuff gets crazy
- your code gets **cluttered with jobs**, that are not being used anymore
- your co-workers always need to be reminded to **execute that one job** after some database changes
- you often seed or process data **in a migration file** (which is a big no-no!)

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

[](#installation)

Require this package with composer:

```
composer require timokoerber/laravel-one-time-operations
```

Create the required table in your database:

```
php artisan migrate
```

Now you're all set!

Commands
--------

[](#commands)

### Create operation files

[](#create-operation-files)

```
php artisan operations:make  // create operation file
```

### Process operations

[](#process-operations)

```
php artisan operations:process                   // process operation files
php artisan operations:process --sync            // force syncronously execution
php artisan operations:process --async           // force asyncronously execution
php artisan operations:process --test            // dont flag operations as processed
php artisan operations:process   // re-run one specific operation
```

### Show operations

[](#show-operations)

```
php artisan operations:show            // show all operations
php artisan operations:show pending    // show pending operations
php artisan operations:show processed  // show processed operations
php artisan operations:show disposed   // show disposed operations

php artisan operations:show pending processed disposed  // use multiple filters
```

Tutorials
---------

[](#tutorials)

### CI/CD &amp; Deployment-Process

[](#cicd--deployment-process)

The *One-Time Operations* work exactly like [Laravel Migrations](https://laravel.com/docs/9.x/migrations). Just process the operations *after your code was deployed and the migrations were migrated*. You can make it part of your deployment script like this:

```
...
 - php artisan migrate
 - php artisan operations:process
...
```

### Edit config

[](#edit-config)

By default, the following elements will be created in your project:

- the table `operations` in your database
- the directory `operations` in your project root directory

If you want to use a different settings just publish and edit the config file:

```
php artisan vendor:publish --provider="TimoKoerber\LaravelOneTimeOperations\Providers\OneTimeOperationsServiceProvider"
```

This will create the file `config/one-time-operations.php` with the following content.

```
// config/one-time-operation.php

return [
    'directory' => 'operations',
    'table' => 'operations',
];
```

Make changes as you like.

### Create One-Time Operation files

[](#create-one-time-operation-files)

[![Laravel One-Time Operations - Create One-Time Operation files](https://user-images.githubusercontent.com/65356688/224433928-721b1261-b7ad-40c6-a512-d0f5b5fa0cbf.png)](https://user-images.githubusercontent.com/65356688/224433928-721b1261-b7ad-40c6-a512-d0f5b5fa0cbf.png)

[![Laravel One-Time Operations - Create One-Time Operation files](https://user-images.githubusercontent.com/65356688/224433323-96b23e84-e22e-4333-8749-ae61cc866cd1.png)](https://user-images.githubusercontent.com/65356688/224433323-96b23e84-e22e-4333-8749-ae61cc866cd1.png)

To create a new operation file execute the following command:

```
php artisan operations:make AwesomeOperation
```

This will create a file like `operations/XXXX_XX_XX_XXXXXX_awesome_operation.php` with the following content.

```
