PHP code example of lawrence / fast-migrate

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

    

lawrence / fast-migrate example snippets




use FastMigrate\FastMigrator;
use Schema;

class ExampleMigration extends FastMigrator
{

    public function up()
    {
        $I = $this;
        $I->wantATable('users')
            ->withStrings('username', 'password');

        $I->wantATable('roles')
            ->withStrings('description');

        $I->wantATable('posts')
            ->withStrings('title', 'content')
            ->withIntegers('score');

        $I->want('users')
            ->toHaveMany('posts');
        $I->want('users')
            ->toHaveOne('roles');

        $I->amReadyForMigration();
    }

    public function down()
    {
        Schema::dropIfExists('users');
        Schema::dropIfExists('posts');
        Schema::dropIfExists('roles');
    }
}