本文整理汇总了PHP中Migration::undo方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::undo方法的具体用法?PHP Migration::undo怎么用?PHP Migration::undo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::undo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRedo
public function handleRedo($p)
{
$version = $p[3];
SqlBeginTransaction();
$filename = Migration::filenameFromVersion($version, 'migration');
Migration::undo($filename, $version, 'migration');
Migration::apply($filename, $version, 'migration');
SqlCommitTransaction();
die;
}
示例2: subMigrations
function subMigrations($p, $s)
{
SqlBeginTransaction();
// make sure the migrations table exists
Migration::initDB();
// have it scan the migrations directory for all available migrations
$versions = Migration::getAllMigrationNames();
// print_r($versions);
$flipped = array_flip($versions);
// query the db for applied migrations in reverse order
$applied = Migration::getAllAppiedMigrationNames();
// print_r($applied);
print_r($versions);
print_r($applied);
// undo all of the migrations
foreach ($applied as $key => $migration) {
Migration::undo($flipped[$migration], $migration);
}
// now, reapply all of them
foreach ($versions as $key => $migration) {
Migration::apply($key, $migration);
}
SqlCommitTransaction();
// apply anything that hasn't been done yet, in the proper order
// $unapplied = array_diff($versions, $applied);
// print_r($unapplied);die();
// foreach($unapplied as $key => $needsApplied)
// {
// Migration::apply($key, $needsApplied);
// }
/*
// make sure the migrations table exists
$schema = SqlGetSchema();
if(!$schema->tableExists('migrations'))
{
SqlAlterSchema("create table migrations (
id serial primary key,
name text not null,
applied int2 not null default 0)");
}
// have it scan the migrations directory for all available migrations
$filenames = ListDir(getcwd() . '/migrations', array('extentions' => array('php')));
$versions = array();
foreach($filenames as $thisFilename)
{
$parts = explode('_', $thisFilename);
$version = $parts[0];
$versions[$thisFilename] = $version;
}
// query the db for applied migrations
$applied = SqlFetchColumn("select name from migrations where applied = 1", array());
// apply anything that hasn't been done yet, in the proper order
$unapplied = array_diff($versions, $applied);
print_r($unapplied);
foreach($unapplied as $key => $needsApplied)
{
// apply the migration
include_once(getcwd() . '/migrations/' . $key);
$className = 'Migration_' . str_replace('.', '_', $needsApplied);
$migration = new $className();
$migration->up();
// mark it as applied
SqlUpsertRow('migrations', array('name' => $needsApplied), array('applied' => 1));
print_r($migration);
}
*/
}