Skip to content
Snippets Groups Projects
Commit 0959bf9c authored by Moritz Strohm's avatar Moritz Strohm Committed by Elmar Ludwig
Browse files

migration 1.271: convert all num attributes (except "seats") to text, closes #269

Closes #269

Merge request studip/studip!799
parent ca931220
No related branches found
No related tags found
No related merge requests found
......@@ -618,6 +618,8 @@ class RoomManagementMigration extends Migration
WHERE property_id = :property_id;"
);
$changed_property_ids = [];
$properties_to_be_modified = $GLOBALS['RESOURCE_PROPERTIES_TO_BE_MODIFIED'];
foreach ($properties_to_be_modified as $old_name => $data) {
//Check if the old property exists:
......@@ -740,6 +742,8 @@ class RoomManagementMigration extends Migration
}
}
$changed_property_ids[] = $final_property_id;
if ($duplicate_ids) {
$this->write(
sprintf(
......@@ -815,6 +819,20 @@ class RoomManagementMigration extends Migration
);
}
//All old properties of type "num" that have not been modified yet
//and which are not the "seats" property will be converted to the
//type "text" so that they continue to be represented in a text input
//instead of being represented in a number input:
$num_to_text_stmt = $db->prepare(
"UPDATE `resource_property_definitions`
SET `type` = 'text'
WHERE
`type` = 'num'
AND `name` <> 'seats'
AND `property_id` NOT IN ( :changed_property_ids )"
);
$num_to_text_stmt->execute(['changed_property_ids' => $changed_property_ids]);
$this->write(
'Finished migrating existing properties.'
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment