Download the PHP package orisintel/laravel-online-migrator without Composer
On this page you can find all versions of the php package orisintel/laravel-online-migrator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download orisintel/laravel-online-migrator
More information about orisintel/laravel-online-migrator
Files in orisintel/laravel-online-migrator
Package laravel-online-migrator
Short Description Apply Laravel's database migrations with minimal disruptions using tools like Percona Online Schema Change
License MIT
Homepage https://github.com/orisintel/laravel-online-migrator
Informations about the package laravel-online-migrator
Laravel Online Migrator
This package minimizes disruptions when applying Laravel's database migrations using tools like Percona Online Schema Change or InnoDB Online DDL. 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
You can install the package via composer:
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
Publish the configuration file:
If not using discovery then add the provider to config/app.php
:
If changing tables with enum
columns consider working around "Unknown database
type enum requested" by tweaking config/online-migrator.php
:
or .env
with DOCTRINE_ENUM_MAPPING=string
Usage
Run Artisan's migrate to apply migrations online*:
*Limitations are documented below.
Preview what changes it would make:
Add PTOSC options using environment variables:
Flag migrations known to be incompatible with this tool using the built-in trait:
Use a different strategy for a single migration:
Do not combine queries for a migration when using PTOSC:
Adding foreign key with index to existing table:
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
- Adding not-null columns requires a default
- Renaming a column or dropping a primary key have additional risks
- 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 separateSchema::table()
call for all FKs in the migration
- With InnoDB Online DDL
- See the MySQL Online DDL documentation
- May be problematic on AWS Aurora
- 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
- Use non-selecting queries like
Testing
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
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Paul R. Rogers
- All Contributors
- Percona Team for
pt-online-schema-change
License
The MIT License (MIT). Please see License File for more information.