Run patches migration style in your Laravel applications.

Overview

Package Logo

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package generates patch files in the same fashion Laravel generates migrations. Each file is timestamped with an up and a down method and is associated with a batch. You may run or rollback patches with the commands below.

This is a very simple package. It runs whatever is in your up and down methods on each patch in the order the patches are defined. It currently does not handle any errors or database transactions, please make sure you account for everything and have a backup plan when running patches in production.

Installation

You can install the package via composer:

composer require rappasoft/laravel-patches

You can publish and run the migrations with:

php artisan vendor:publish --provider="Rappasoft\LaravelPatches\LaravelPatchesServiceProvider" --tag="laravel-patches-migrations"
php artisan migrate

Usage

Making Patches

php artisan make:patch patch_1_0_0

This created a timestamped patch file under database/patches.

Running Patches

To run all available patches:

php artisan patch

To run each available patch in its own batch:

php artisan patch --step

To force the patches to run in production (deploy scripts, etc.):

php artisan patch --force

Rolling Back Patches

To rollback all patches of the last batch:

php artisan patch:rollback

To rollback the last X patches regardless of batch:

php artisan patch:rollback --step=X

Patch File Helpers

You may use the following helper commands from your patch files:

Log a line to the patches log column (up method only):

$this->log('10 users modified');

Call an Artisan command with options:

$this->call($command, $parameters);

Call a seeder by class name:

$this->seed($class);

Truncate a table by name:

$this->truncate($table);

Note: Does not disable foreign key checks.

Please feel free to PR new helpers.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
This package provides a trait to run your tests against a MinIO S3 server.

Laravel MinIO Testing Tools This package provides a trait to run your tests against a MinIO S3 server. đź“ť Blog post: https://protone.media/en/blog/how

🧑‍🔬 The missing assertions for your views in your Laravel applications.
🧑‍🔬 The missing assertions for your views in your Laravel applications.

Laravel View Assertions The missing assertions for your views in your Laravel applications. Installation You'll have to follow a couple of simple step

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant

The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. B

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups.

Tenancy for Laravel Enabling awesome Software as a Service with the Laravel framework. This is the successor of hyn/multi-tenant. Feel free to show su

A wrapper package to run mysqldump from laravel console commands.

A wrapper package to run mysqldump from laravel console commands.

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously

This Laravel Nova tool lets you run artisan and bash commands directly from Nova 4 or higher.
This Laravel Nova tool lets you run artisan and bash commands directly from Nova 4 or higher.

Laravel Nova tool for running Artisan & Shell commands. This Nova tool lets you run artisan and bash commands directly from nova. This is an extended

Laravel Boilerplate provides a very flexible and extensible way of building your custom Laravel applications.
Laravel Boilerplate provides a very flexible and extensible way of building your custom Laravel applications.

Laravel Boilerplate Project Laravel Boilerplate provides a very flexible and extensible way of building your custom Laravel applications. Table of Con

A kernel designed to run one and only one application in a virtualized environment
A kernel designed to run one and only one application in a virtualized environment

nanos Nanos is a new kernel designed to run one and only one application in a virtualized environment. It has several constraints on it compared to a

Comments
  • Custom table name

    Custom table name

    It would be nice to have a configurable table name for the migration.

    https://github.com/rappasoft/laravel-patches/blob/87cd753f203c7bf9f37b0bd92a1dc75dfa523c9b/src/Patcher.php#L61

    opened by krnsptr 2
Releases(v2.0.1)
Owner
Anthony Rappa
Certified Laravel | Laravel Boilerplate Creator | PHP
Anthony Rappa
Let's base your Laravel project with PROS style

Purpose This library is for convenient methods that use to register code base for Laravel project Target We aimed to reduce complexity for real projec

Protean Studios Co., Ltd. 4 Mar 29, 2022
Make Laravel Pivot Tables using the new Laravel 9 closure migration format

This will allow you to create pivot table migration files using the new Laravel 9 closure migration format by simply passing two models.

Jose Jimenez 16 Aug 23, 2022
PHP 7 Migration Assistant Report (MAR)

Introduction What is PHP 7 Migration Assistant Report(MAR)? PHP 7 MAR, or just "php7mar", is a command line utility to generate reports on existing PH

Alexia E. Smith 790 Dec 8, 2022
Magento Data Migration Tool

Overview We're pleased you're considering moving from the world's #1 eCommerce platform—Magento 1.x—to the eCommerce platform for the future, Magento

Magento 327 Jan 4, 2023
NYC Checkbook - Drupal 9 migration

Checkbook NYC Checkbook NYC is an open source financial transparency web application. Checkbook provides transparent access to a city's or other juris

Office of the Comptroller, City of New York 1 Jan 14, 2022
Validate PHP database migration files for compliance with best practices. Ensure db migrations are irreversible.

PHP DB Migration Validator Introduction In modern PHP frameworks such as Symfony and Laravel, migrations usually have up and down methods. In up metho

Anton Komarev 17 Dec 14, 2022
Laravel style jquery validation plugin

Validator Laravel style jquery validation plugin Validator is a jQuery plugin that emulates the validation class found in the laravel framework. Usage

David Thingsaker 5 Aug 31, 2022
Livewire UI components with tailwind base style

WireUI ?? Documentation Wire UI is a library of components and resources to empower your Laravel and Livewire application development. Starting a new

WireUi 811 Jan 2, 2023
A lightweight PHP paginator, for generating pagination controls in the style of Stack Overflow and Flickr.

PHP Paginator A lightweight PHP paginator, for generating pagination controls in the style of Stack Overflow and Flickr. The "first" and "last" page l

Jason Grimes 370 Dec 21, 2022
This package enables you to create and run a fully functioning WebSocket server in your Laravel app.

This package enables you to create and run a fully functioning WebSocket server in your Laravel app. It can optionally receive messages broadcast over ZeroMQ.

Asked.io 181 Oct 6, 2022