19declare(strict_types=1);
31 private \ilDBInterface
$db;
35 return 'Migrate test settings from tst_tests to tst_test_settings';
45 return [new \ilDatabaseInitializedObjective()];
55 $columns = implode(
',', array_keys(self::SETTINGS_COLUMNS));
56 $row = $this->db->fetchAssoc(
57 $this->db->query(
"SELECT test_id, {$columns} FROM tst_tests WHERE settings_id IS NULL LIMIT 1")
60 $settings_id = $this->db->nextId(
'tst_test_settings');
63 foreach ($row as $column_name => $value) {
64 if (isset(self::SETTINGS_COLUMNS[$column_name])) {
65 [$column_def] = self::SETTINGS_COLUMNS[$column_name];
67 if ($column_name ===
'reporting_date') {
73 $value = (
int) $value;
76 $setting_data[$column_name] = [$column_def[
'type'], $value];
80 $this->db->insert(
'tst_test_settings', $setting_data);
90 $result = $this->db->query(
"SELECT COUNT(test_id) AS cnt FROM tst_tests WHERE settings_id IS NULL");
91 return (
int) $this->db->fetchObject($result)->cnt;
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.
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)