PHPackages                             orisintel/laravel-online-migrator - 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. orisintel/laravel-online-migrator

Abandoned → [always-open/laravel-online-migrator](/?search=always-open%2Flaravel-online-migrator)Library[Database &amp; ORM](/categories/database)

orisintel/laravel-online-migrator
=================================

Apply Laravel's database migrations with minimal disruptions using tools like Percona Online Schema Change

v6.0(5y ago)4482.2k↓50%3[4 issues](https://github.com/orisintel/laravel-online-migrator/issues)[2 PRs](https://github.com/orisintel/laravel-online-migrator/pulls)MITPHPPHP ^7.3CI failing

Since Sep 11Pushed 5y ago12 watchersCompare

[ Source](https://github.com/orisintel/laravel-online-migrator)[ Packagist](https://packagist.org/packages/orisintel/laravel-online-migrator)[ Docs](https://github.com/orisintel/laravel-online-migrator)[ RSS](/packages/orisintel-laravel-online-migrator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (6)Versions (22)Used By (0)

Laravel Online Migrator
=======================

[](#laravel-online-migrator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8e8b896fd86821311693f986bc57c61cb7b261b1229c91f5adaca674de819c5b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f726973696e74656c2f6c61726176656c2d6f6e6c696e652d6d69677261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/orisintel/laravel-online-migrator)[![Build Status](https://camo.githubusercontent.com/e9d2e2bc77640801e9df72e671c33ebdd9bcd5b35599ca467ed97ca0619fd3ec/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6f726973696e74656c2f6c61726176656c2d6f6e6c696e652d6d69677261746f722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/orisintel/laravel-online-migrator)[![Total Downloads](https://camo.githubusercontent.com/76a406441a7f46214c4da30564c16983b0ac99a90a064ec5b642c8c64c91f8bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f726973696e74656c2f6c61726176656c2d6f6e6c696e652d6d69677261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/orisintel/laravel-online-migrator)

This package minimizes disruptions when applying Laravel's database migrations using tools like [Percona Online Schema Change](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html)or [InnoDB Online DDL](https://dev.mysql.com/doc/refman/5.6/en/innodb-online-ddl.html). For example, one can write (mostly) standard Laravel migration files then run "php artisan migrate". Database changes will be automatically converted into PTOSC commands or online DDL queries.

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

[](#installation)

You can install the package via composer:

```
composer require orisintel/laravel-online-migrator
```

The `pt-online-schema-change` command from Percona's toolkit must be in the path where Artisan will be run, unless InnoDB Online DDL is being used exclusively.

### Configuration

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider='OrisIntel\OnlineMigrator\OnlineMigratorServiceProvider'
```

If not using discovery then add the provider to `config/app.php`:

```
'providers' => [
    // ...
    OrisIntel\OnlineMigrator\OnlineMigratorServiceProvider::class,
```

If changing tables with `enum` columns consider working around "Unknown database type enum requested" by tweaking `config/online-migrator.php`:

```
  'doctrine-enum-mapping' => env('DOCTRINE_ENUM_MAPPING', 'string'),
```

or `.env` with `DOCTRINE_ENUM_MAPPING=string`

Usage
-----

[](#usage)

Run Artisan's migrate to apply migrations online\*:

```
php artisan migrate
```

\*Limitations are documented below.

Preview what changes it would make:

```
php artisan migrate --pretend
```

Add PTOSC options using environment variables:

```
PTOSC_OPTIONS='--recursion-method=none'  php artisan migrate
```

Flag migrations known to be incompatible with this tool using the built-in trait:

```
class MyMigration extends Migration
{
    use \OrisIntel\OnlineMigrator\OnlineIncompatible
```

Use a different strategy for a single migration:

```
class MyMigration extends Migration
{
    use \OrisIntel\OnlineMigrator\InnodbOnlineDdl
```

Do not combine queries for a migration when using PTOSC:

```
class MyMigration extends Migration
{
    use \OrisIntel\OnlineMigrator\CombineIncompatible
```

Adding foreign key with index to existing table:

```
class MyColumnWithFkMigration extends Migration
{
    public function up()
    {
        Schema::table('my_table', function ($table) {
            $table->integer('my_fk_id')->index();
        });

        Schema::table('my_table', function ($table) {
            $table->foreign('my_fk_id')->references('id')->on('my_table2');
```

Limitations
-----------

[](#limitations)

- Only supports Mysql, specifically those versions supported by PTOSC v3
- With PTOSC
    - Adding unique indexes may cause data loss unless tables are manually checked beforehand [because of how PTOSC works](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#id7)
    - Adding not-null columns [requires a default](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#cmdoption-pt-online-schema-change-alter)
    - Renaming a column or dropping a primary key [have additional risks](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#id1)
    - Foreign key creation should be done separately from column creation or duplicate indexes may be created with slightly different naming
        - Close the `Schema::create()` call and make a separate `Schema::table()`call for all FKs in the migration
- With InnoDB Online DDL
    - See the [MySQL Online DDL documentation](https://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-overview.html)
    - May be [problematic on AWS Aurora](https://medium.com/@soomiq/why-you-should-not-use-mysql-5-6-online-ddl-on-aws-aurora-40985d5e90f5)
- Stateful migrations, like those selecting *then* saving rows, will instead need to do one of the following:
    - Use non-selecting queries like `MyModel::where(...)->update(...)`
    - Pipe the raw SQL like `\DB::statement('UPDATE ... SET ... WHERE ...');`
    - Use the `OnlineMigratorIncompatible` trait to mark the migration as incompatible

### Testing

[](#testing)

```
composer test
```

Output is verbose because `passthru` is used to help debug production problems. Executing as `phpunit --testdox` may be more readable until the verbosity can be tamed.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Paul R. Rogers](https://github.com/paulrrogers)
- [All Contributors](../../contributors)
- [Percona Team](https://www.percona.com/about-percona/team) for `pt-online-schema-change`

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 88.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~50 days

Recently: every ~87 days

Total

17

Last Release

2000d ago

Major Versions

v1.4.0 → v2.0.02019-01-10

v2.1.2 → v3.02019-12-10

v3.1 → v4.0.02020-04-16

v4.0.0 → v5.02020-10-09

v5.0 → v6.02020-11-25

PHP version history (3 changes)v0.5.0PHP ^7.1

v4.0.0PHP ^7.2.5

v6.0PHP ^7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/b116525a1bd1456044dc2edc80dd04a09806549a38945eb9b905b143a642c4bd?d=identicon)[tomschlick](/maintainers/tomschlick)

![](https://www.gravatar.com/avatar/dd541eff6b242f95c9d1a13761ddc93f957555c81116bb45818f371cf2e472e7?d=identicon)[paulrrogers](/maintainers/paulrrogers)

![](https://www.gravatar.com/avatar/7006eb1e1f263337f802453bc232edc6edc13324a004c297f8e0c5dbe019ba96?d=identicon)[orisintel](/maintainers/orisintel)

---

Top Contributors

[![paulrrogers](https://avatars.githubusercontent.com/u/5749738?v=4)](https://github.com/paulrrogers "paulrrogers (15 commits)")[![qschmick](https://avatars.githubusercontent.com/u/5342767?v=4)](https://github.com/qschmick "qschmick (1 commits)")[![tomschlick](https://avatars.githubusercontent.com/u/70184?v=4)](https://github.com/tomschlick "tomschlick (1 commits)")

---

Tags

hacktoberfestlaravel-frameworkmigrationlaravelmigrationorisintellaravel-online-migrator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/orisintel-laravel-online-migrator/health.svg)

```
[![Health](https://phpackages.com/badges/orisintel-laravel-online-migrator/health.svg)](https://phpackages.com/packages/orisintel-laravel-online-migrator)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11120.2M21](/packages/anourvalar-eloquent-serialize)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[ucan-lab/laravel-dacapo

Laravel migration support tools

110343.8k](/packages/ucan-lab-laravel-dacapo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
