1. Go to this page and download the library: Download nish/db-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/ */
nish / db-migration example snippets
class Foo implements DbMigration
{
public function up(PDO $pdo)
{
$pdo->exec('
create table foo(
foo_id serial primary key,
name text not null,
body text
)
');
}
public function down(PDO $pdo)
{
$pdo->exec('drop table foo');
}
}
class Foo implements DbMigration
{
public function up(PDO $pdo)
{
$pdo->exec('
create table foo(
foo_id serial primary key,
name text not null,
body text,
created_at timestamp not null default CURRENT_TIMESTAMP
)
');
}
public function down(PDO $pdo)
{
$pdo->exec('drop table foo');
}
}