本文整理汇总了PHP中Migration::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::create方法的具体用法?PHP Migration::create怎么用?PHP Migration::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: migrate_all
public static function migrate_all(&$messages)
{
$migrations = static::get_migrations();
$messages = [];
foreach (Migration::all() as $migration) {
if (isset($migrations[$migration->hash])) {
unset($migrations[$migration->hash]);
}
}
$db = Database::instance();
foreach ($migrations as $key => $info) {
$message = sprintf('Executing migration: \'%s\' with hash: %s', $info['class'], $key);
$db->begin();
try {
static::resolve($info['file'], $info['class'])->up();
if (Migration::create(['hash' => $key, 'name' => $info['class']])->saved()) {
$messages[] = [$message];
} else {
$messages[] = [$message, 'Failed to save migration to database'];
}
$db->commit();
} catch (Exception $e) {
$db->rollback();
$messages[] = [$message, $e->getMessage()];
return $messages;
}
}
return $messages;
}
示例2: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Migration::create([]);
}
}