Download the PHP package fndmiranda/data-migration without Composer
On this page you can find all versions of the php package fndmiranda/data-migration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package data-migration
Data Migration
Data migrations from Laravel
This package simplifies the migration and synchronization of data between the application and the database, allowing you to control for example settings or permissions lists. Provides resources to view the status and changes not yet made, migrate and synchronize the data.
Installation
Usage
You may generate an data migration of the data-migration:make Artisan command:
This command will generate a data migration at app/DataMigrations/PermissionDataMigration.php. The data migration will contain the model, data, and options methods.
Property order (optional)
The order property defines the order of execution of data migrations class, default value is 0.
Property tag (optional)
The tag property is used in filter of data-migrations search, default value is production, if another value is
set, it will have to pass to the tag parameter when executing the command.
Method model
Method to specify the model bound to the data migration class.
Method data
Method to specify the data to be migrated.
Method options
The options method to specify the parameters to be used in the migration.
The following keys are available as options:
| Key | Description | Type |
|---|---|---|
| identifier | Column with unique value to validate status. | string |
| show | Columns to show in commands output. | array |
| relations | Relationships options, see the usage with relationships. | array |
Run a data migration
You can run a data migration via command or facade.
Show the status of each data with the database with data-migration:status Artisan command:
Specifying the paths to search for data migrations.
Specifying the tags to search for data migrations.
Run data-migration:status only specific a data migration.
Output:
Or with DataMigration facade:
Show changes between data migration and database with data-migration:diff Artisan command:
Specifying the paths to search for data migrations.
Specifying the tags to search for data migrations.
Run data-migration:diff only specific a data migration.
Output:
Or with DataMigration facade:
Migrate data from a data migration to the database. Only necessary operations with status to create will be executed
with data-migration:migrate Artisan command:
Specifying the paths to search for data migrations.
Specifying the tags to search for data migrations.
Run data-migration:migrate only specific a data migration.
Output:
Or with DataMigration facade:
Synchronize data from a data migration with the database. All necessary create, update, and delete operations will be
performed with data-migration:sync Artisan command:
Specifying the paths to search for data migrations.
Specifying the tags to search for data migrations.
Run data-migration:sync only specific a data migration.
Output:
Or with DataMigration facade:
Show a list of data-migrations with data-migration:list Artisan command:
Specifying the paths to search for data migrations.
Specifying the tags to search for data migrations.
Usage with relationships
Example of a permissions model with a relationship for dependencies of type belongsToMany with pivot_example_1 and pivot_example_2, and a relationship for brand of type belongsTo to exemplify a data migration.
Method data with relationships
The data method to specify the data to be migrated with relationships.
Method options with relationships
The options method with relationships to specify the parameters to be used in the data migration.
The following keys are available as relationships options:
| Key | Description | Type |
|---|---|---|
| relation | Name of the relationship of the model. | string |
| type | Model relationship type, belongsToMany or belongsTo. |
string |
| identifier | Column with unique value to validate status (only with belongsToMany). |
string |
| show | Columns to show in commands output (only with belongsToMany). |
array |
Events
Events when start and finish are available for when running a data-migration:migrate or data-migration:sync Artisan command.
onStartMigrate
Create the onStartMigrate method in your data migration to be called before the data-migration:migrate Artisan command is executed.
onFinishMigrate
Create the onFinishMigrate method in your data migration to be called after the data-migration:migrate Artisan command is executed.
onStartSync
Create the onStartSync method in your data migration to be called before the data-migration:sync Artisan command is executed.
onFinishSync
Create the onFinishSync method in your data migration to be called after the data-migration:sync Artisan command is executed.
Testing
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.