PHP code example of northbees / data-migrations

1. Go to this page and download the library: Download northbees/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/ */

    

northbees / data-migrations example snippets


// config/data-migrations.php

return [
    'table'        => 'data_migrations',
    'failed_table' => 'failed_data_migrations',
    'path'         => database_path('data-migrations'),

    // Low-priority jobs are delayed until this window
    'off_peak_start' => '00:00',
    'off_peak_end'   => '06:00',

    // Queue names
    'queue_high' => 'default',
    'queue_low'  => 'data-migrations-low',

    // Safety
    'prevent_deletes_in_production' => false,
];



declare(strict_types=1);

namespace Database\DataMigrations;

use NorthBees\DataMigrations\Contracts\DataMigrationInterface;
use NorthBees\DataMigrations\Enums\MigrationPriority;
use NorthBees\DataMigrations\Enums\MigrationType;

class FixUsersEmail implements DataMigrationInterface
{
    public function up(): void
    {
        // Perform data migration logic here.
    }

    public function getPriority(): MigrationPriority
    {
        return MigrationPriority::HIGH;
    }

    public function getType(): MigrationType
    {
        return MigrationType::ALTER;
    }

    public function isTransactional(): bool
    {
        return true;
    }
}
bash
php artisan vendor:publish --tag=data-migrations-config
php artisan migrate
bash
php artisan vendor:publish --tag=data-migrations-migrations
bash
php artisan make:data-migration fix_users_email --priority=high --type=alter
json
{
    "scripts": {
        "post-deploy": [
            "@php artisan migrate --force",
            "@php artisan data-migrate:run"
        ]
    }
}
bash
php artisan migrate --force
php artisan data-migrate:run