ubuntu@ubuntu-xenial:/vagrant/sanrio_sys/web$ vendor/bin/phpmig -vvv status
Status Migration ID Migration Name
-----------------------------------------
up 20161206113249 CraeteTable1
ubuntu@ubuntu-xenial:/vagrant/sanrio_sys/web$ vendor/bin/phpmig -vvv status
Status Migration ID Migration Name
-----------------------------------------
down 20161206113249 CraeteTable1
ubuntu@ubuntu-xenial:/vagrant/web$ vendor/bin/phpmig -vvv migrate
== 20161206113249 CraeteTable1 migrating
== 20161206113249 CraeteTable1 migrated 0.0989s
ubuntu@ubuntu-xenial:/vagrant/web$ vendor/bin/phpmig -vvv status
Status Migration ID Migration Name
-----------------------------------------
up 20161206113249 CraeteTable1
ubuntu@ubuntu-xenial:/vagrant/web$ vendor/bin/phpmig -vvv rollback
== 20161206113249 CraeteTable1 reverting
== 20161206113249 CraeteTable1 reverted 0.0935s
ubuntu@ubuntu-xenial:/vagrant/web$ vendor/bin/phpmig -vvv status
Status Migration ID Migration Name
-----------------------------------------
down 20161206113249 CraeteTable1
<?php
use Phpmig\Migration\Migration;
use Store\Migration\Helper;
class CraeteTable1 extends Migration
{
/**
* Do the migration
*/
public function up()
{
$sql = <<<EOS
create table hogehoge (
id int identity(1,1) not null,
name nvarchar(1024) not null)
EOS;
// Get PDO instance from container
$container = $this->getContainer();
$con = $container['db'];
$con->beginTransaction();
$con->exec($sql);
$con->commit();
}
/**
* Undo the migration
*/
public function down()
{
$sql = <<<EOS
drop table hogehoge
EOS;
// Get PDO instance from container
$container = $this->getContainer();
$con = $container['db'];
$con->beginTransaction();
$con->exec($sql);
$con->commit();
}
}
I need this function to my job.
Test result.
Sample phpmig.php (Pimple version bumped to 3.x)
Sample migration file