aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2022-07-15 10:24:41 +0000
committerElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2022-07-15 10:24:41 +0000
commit0959bf9c65a9320dc7e9fb51720aec9483806090 (patch)
tree920385235f651ad9856ec15265c76079fdd6e554
parentca93122050607f51afd4d571680bd2b4d0fdab10 (diff)
migration 1.271: convert all num attributes (except "seats") to text, closes #269
Closes #269 Merge request studip/studip!799
-rw-r--r--db/migrations/1.271_room_management_migration.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrations/1.271_room_management_migration.php b/db/migrations/1.271_room_management_migration.php
index 8fd748b..8edb190 100644
--- a/db/migrations/1.271_room_management_migration.php
+++ b/db/migrations/1.271_room_management_migration.php
@@ -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.'
);