PHP code example of topthink / think-migration

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

    

topthink / think-migration example snippets




use Phinx\Migration\AbstractMigration;

class YourMigrationName extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('followers', ['id' => false, 'primary_key' => ['user_id', 'follower_id']]);
        $table->addColumn('user_id', 'integer')
            ->addColumn('follower_id', 'integer')
            ->addColumn('created', 'datetime')
            ->addIndex(['email','username'], ['limit' => ['email' => 5, 'username' => 2]])
            ->addIndex('user_guid', ['limit' => 6])
           ->create();
    }
 
}
bash
php think migrate:create YourMigrationName
bash
php think migrate:run
bash
php think migrate:rollback