PHP code example of vierge-noire / cakephp-test-migrator

1. Go to this page and download the library: Download vierge-noire/cakephp-test-migrator 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/ */

    

vierge-noire / cakephp-test-migrator example snippets


\CakephpTestMigrator\Migrator::migrate();

\CakephpTestMigrator\Migrator::migrate([], true);
// is the same as
\CakephpTestMigrator\Migrator::migrate([], ['verbose' => true]);

\CakephpTestMigrator\Migrator::migrate([
    ['connection' => 'test', 'source' => 'TestFolder'],       
    ['plugin' => 'FooPlugin', 'connection' => 'FooConnection'],      
    ['source' => 'BarFolder'],
    ...
 ], ['verbose' => true]);

// In config/app.php
'test' => [
    'className' => Connection::class,
    'driver' => Mysql::class,
    'persistent' => false,
    'timezone' => 'UTC',
    'flags' => [],
    'cacheMetadata' => true,
    'quoteIdentifiers' => false,
    'log' => false,
    'migrations' => [
        ['plugin' => 'FooPlugin'],      
        ['source' => 'BarFolder'],
    ],
],

$migrator = Migrator::migrate();
$connectionsWithModifiedStatus = $migrator->getConnectionsWithModifiedStatus();

$migrator = Migrator::migrate([], ['truncate' => false]);
// do something with the migrated database (bake fixtures, etc)
$migrator->truncate();

Migrator::dump('test', 'path/to/file.sql')

Migrator::dump('test', [
    'path1/to/file1.sql',
    'path2/to/file2.sql',
])

Migrator::dump('test', 'path/to/file.sql', true)