PHP code example of lacodix / laravel-data-migrations

1. Go to this page and download the library: Download lacodix/laravel-data-migrations library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lacodix / laravel-data-migrations example snippets




return [
    'table' => 'migrations_data',
];



use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        DB::table('example_settings')->insert([
            'key' => 'timezone',
            'value' => 'UTC',
        ]);
    }

    public function down(): void
    {
        DB::table('example_settings')->where('key', 'timezone')->delete();
    }
};
shell
php artisan make:data-migration insert_example_setting
php artisan migrate-data
php artisan migrate-data:rollback
shell
php artisan make:data-migration insert_example_setting --path=database/custom_data
php artisan migrate-data --path=database/custom_data --database=sqlite --step
php artisan migrate-data:rollback --path=database/custom_data --database=sqlite --step=1
php artisan migrate-data --path=/absolute/path/to/data_migrations --realpath
php artisan migrate-data:rollback --path=/absolute/path/to/data_migrations --realpath