PHP code example of antonyz89 / yii2-migrate

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

    

antonyz89 / yii2-migrate example snippets


public $ignoreColumns = [
    'company_id'
];

public $autoGenerateIndexAndForeignKey = true;

$options = [
    'table' => '{{%user}}',
    'ref_table' => 'company',
    'ref_table_id' => 'id',
    'delete' => 'CASCADE',
    'update' => 'CASCADE'
];

// in migrate
$this->indexAndForeignKey('company_id', $options);

use antonyz89\migrate\Migration;

Migration::$onDelete = 'RESTRICT'; // default: CASCADE
Migration::$onUpdate = 'CASCADE'; // default: CASCADE