PHP code example of jmsfwk / fluent-phinx

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

    

jmsfwk / fluent-phinx example snippets




use jmsfwk\FluentPhinx\Fluent;
use jmsfwk\FluentPhinx\Schema\Blueprint;
use Phinx\Migration\AbstractMigration;

class CreateUsersTable extends AbstractMigration
{
    use Fluent;

    public function change()
    {
        $this->create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            
            $table->id = false; // Turn off automatic id column
            $table->primary_key = 'id'; // Set the 'id' column as the primary key
        });
    }
}

$this->create('users', function (Blueprint $table) {
    $table->increments('id');
});

$this->update('users', function (Blueprint $table) {
    $table->integer('votes');
});

$table->string('email')->unique();

$table->unique('email');

$table->index(['account_id', 'created_at']);

$table->unique('email', 'unique_email');