19declare(strict_types=1);
32 private \ilDBInterface
$db;
37 return 'Migrate test settings from tst_tests to tst_test_settings';
47 return [new \ilDatabaseInitializedObjective()];
58 $columns = implode(
',', array_keys(self::SETTINGS_COLUMNS));
59 $row = $this->db->fetchAssoc(
60 $this->db->query(
"SELECT test_id, {$columns} FROM tst_tests WHERE settings_id IS NULL LIMIT 1")
63 $settings_id = $this->db->nextId(
'tst_test_settings');
66 foreach ($row as $column_name => $value) {
67 if (isset(self::SETTINGS_COLUMNS[$column_name])) {
68 [$column_def] = self::SETTINGS_COLUMNS[$column_name];
70 if ($column_name ===
'reporting_date') {
73 if ($column_name ===
'nr_of_tries' && $value > 127) {
75 "ID {$settings_id}: Tried to set nr_of_tries to {$value}, which is too high. Setting it to 127 instead."
82 $value = (
int) $value;
85 $setting_data[$column_name] = [$column_def[
'type'], $value];
89 $this->db->insert(
'tst_test_settings', $setting_data);
99 $result = $this->db->query(
"SELECT COUNT(test_id) AS cnt FROM tst_tests WHERE settings_id IS NULL");
100 return (
int) $this->db->fetchObject($result)->cnt;
Wrapper around symfonies input and output facilities to provide just the functionality required for t...
prepare(Environment $environment)
Prepare the migration by means of some environment.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
getPreconditions(Environment $environment)
Objectives the migration depend on.
step(Environment $environment)
Run one step of the migration.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
const RESOURCE_ADMIN_INTERACTION
A migration is a potentially long lasting operation that can be broken into discrete steps.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
columnIsNullable(array $column_def)
convertLegacyDate(string|\DateTimeImmutable|null $date)