:: sql_layer; ?>
::
get('dbal.tools');
if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE))
{
$db_tools->sql_create_table(MIGRATIONS_TABLE, array(
'COLUMNS' => array(
'migration_name' => array('VCHAR', ''),
'migration_depends_on' => array('TEXT', ''),
'migration_schema_done' => array('BOOL', 0),
'migration_data_done' => array('BOOL', 0),
'migration_data_state' => array('TEXT', ''),
'migration_start_time' => array('TIMESTAMP', 0),
'migration_end_time' => array('TIMESTAMP', 0),
),
'PRIMARY_KEY' => 'migration_name',
));
}
$migrator = $phpbb_container->get('migrator');
$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/');
// What is a safe limit of execution time? Half the max execution time should be safe.
$safe_time_limit = (ini_get('max_execution_time') / 2);
while (!$migrator->finished())
{
try
{
$migrator->update();
}
catch (phpbb_db_migration_exception $e)
{
echo $e;
end_update($cache);
}
echo $migrator->last_run_migration['name'] . '
';
// Are we approaching the time limit? If so we want to pause the update and continue after refreshing
if ((time() - $update_start_time) >= $safe_time_limit)
{
//echo '';
echo 'Update not yet completed.
';
echo 'Continue';
end_update($cache);
}
}
if ($orig_version != $config['version'])
{
add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']);
}
echo 'Finished';
end_update($cache);
function end_update($cache)
{
$cache->purge();
?>