Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 712 Bytes

File metadata and controls

30 lines (22 loc) · 712 Bytes

Usage

Basic Example

<?php

use Exo\Handler;
use Exo\History;
use Exo\Migration;

$history = new History();

$history->add('1', Migration::create('users')
    ->addColumn('id', ['type' => 'uuid', 'primary' => true])
    ->addColumn('username', ['type' => 'string', 'unique' => true])
    ->addColumn('password', ['type' => 'string'])
);

$history->add('2', Migration::alter('users')
    ->addColumn('email', ['type' => 'string', 'unique' => true, 'after' => 'username'])
    ->addIndex('email', ['email'])
);

$pdo = new PDO('mysql:dbname=tenant_1234;host=dbhost', 'user', 'pass');
$handler = new Handler($pdo, $history);

// Migrate from version '1' to '2'
$handler->migrate(['1'], '2', true);