Skip to content

Commit

Permalink
Drop temporary migration code (#18694)
Browse files Browse the repository at this point in the history
* Drop temporary migration code

* Update phpstan baseline
  • Loading branch information
AdrienClairembault authored Jan 13, 2025
1 parent ee2df63 commit 7349c9d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 68 deletions.
6 changes: 0 additions & 6 deletions .phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,6 @@
'count' => 3,
'path' => __DIR__ . '/install/migrations/update_10.0.x_to_11.0.0.php',
];
$ignoreErrors[] = [
'message' => '#^Loose comparison using \\=\\= between \'11\\.0\\.0\\-dev\' and \'11\\.0\\.0\\-dev\' will always evaluate to true\\.$#',
'identifier' => 'equal.alwaysTrue',
'count' => 1,
'path' => __DIR__ . '/install/migrations/update_10.0.x_to_11.0.0/form.php',
];
$ignoreErrors[] = [
'message' => '#^Empty array passed to foreach\\.$#',
'identifier' => 'foreach.emptyArray',
Expand Down
62 changes: 0 additions & 62 deletions install/migrations/update_10.0.x_to_11.0.0/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,68 +269,6 @@
$ADDTODISPLAYPREF['Glpi\Form\Form'] = [1, 80, 86, 3, 4];
$ADDTODISPLAYPREF['Glpi\Form\AnswersSet'] = [1, 3, 4];

// Temporary migration code to cover dev migrations
// TODO: Should be removed from the final release
if (GLPI_VERSION == "11.0.0-dev") {
$migration->addField("glpi_forms_forms", "is_draft", "bool");
$migration->addKey("glpi_forms_forms", "is_draft");
$migration->changeField("glpi_forms_forms", "header", "header", "longtext");
$migration->changeField("glpi_forms_sections", "description", "description", "longtext");
$migration->changeField("glpi_forms_questions", "description", "description", "longtext");

// Deletion of subtype, use final type in `type` field instead
if ($DB->fieldExists("glpi_forms_questions", "subtype")) {
$migration->dropField("glpi_forms_questions", "subtype");

// Set a concrete type instead the "parent type" that was used before this migration
$questions = $DB->request([
'SELECT' => ['id', 'type'],
'FROM' => 'glpi_forms_questions',
]);
foreach ($questions as $question) {
if ($question['type'] == "Glpi\Form\QuestionType\AbstractQuestionTypeShortAnswer") {
// Default subtype for short answers
$new_type = "Glpi\Form\QuestionType\QuestionTypeShortText";
} elseif ($question['type'] == "Glpi\Form\QuestionType\QuestionTypeLongText") {
// Long answers have no sub types, use parent
$new_type = $question['type'];
} else {
// Unknown type
continue;
}

$migration->addPostQuery($DB->buildUpdate(
'glpi_forms_questions',
['type' => $new_type],
['id' => $question['id']]
));
}
}

$migration->addField("glpi_forms_answerssets", "entities_id", "fkey");
$migration->addKey("glpi_forms_answerssets", "entities_id");
$migration->addField("glpi_forms_destinations_formdestinations", "config", "JSON NOT NULL COMMENT 'Extra configuration field(s) depending on the destination type'");

$migration->addField("glpi_forms_forms", "illustration", "string");
$migration->addField("glpi_forms_forms", "description", "text");

$migration->addField("glpi_forms_forms", "forms_categories_id", "fkey");
$migration->addKey("glpi_forms_forms", "forms_categories_id");

$migration->addField("glpi_forms_sections", "uuid", "string");
$migration->addKey("glpi_forms_sections", "uuid", type: 'UNIQUE');

$migration->addField("glpi_forms_questions", "uuid", "string");
$migration->addField("glpi_forms_questions", "forms_sections_uuid", "string");
$migration->addKey("glpi_forms_questions", "uuid", type: 'UNIQUE');
$migration->addKey("glpi_forms_questions", "forms_sections_uuid");

$migration->addField("glpi_forms_comments", "uuid", "string");
$migration->addField("glpi_forms_comments", "forms_sections_uuid", "string");
$migration->addKey("glpi_forms_comments", "uuid", type: 'UNIQUE');
$migration->addKey("glpi_forms_comments", "forms_sections_uuid");
}

CronTask::register('Glpi\Form\Form', 'purgedraftforms', DAY_TIMESTAMP, [
'state' => CronTask::STATE_WAITING,
'mode' => CronTask::MODE_INTERNAL,
Expand Down

0 comments on commit 7349c9d

Please sign in to comment.