diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2025-04-24 10:48:24 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2025-04-24 10:48:24 +0000 |
| commit | cd8222ba049eca136bb443410022d99dfbc5d0f2 (patch) | |
| tree | 99b46288e335427b3f3bde5555b56497a80c1b88 /db | |
| parent | 3c783c028c229a3e6561500521800e1fac4383ba (diff) | |
distinguish between LTI deployment IDs and LTI resource links in the database, fixes #5330
Closes #5330
Merge request studip/studip!4045
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/6.0.48_add_lti_resource_links_table.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/db/migrations/6.0.48_add_lti_resource_links_table.php b/db/migrations/6.0.48_add_lti_resource_links_table.php new file mode 100644 index 0000000..40bb129 --- /dev/null +++ b/db/migrations/6.0.48_add_lti_resource_links_table.php @@ -0,0 +1,61 @@ +<?php + + +class AddLtiResourceLinksTable extends Migration +{ + public function description() + { + return 'Creates the lti_resource_links table and moves colums from the lti_deployments table into it.'; + } + + protected function up() + { + $db = DBManager::get(); + + //Create the lti_resource_links table: + $db->exec( + "CREATE TABLE IF NOT EXISTS lti_resource_links ( + id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, + deployment_id INT(11) NOT NULL, + course_id CHAR(32) NOT NULL, + position INT(11) NOT NULL DEFAULT 0, + mkdate INT(11) NOT NULL DEFAULT 0, + chdate INT(11) NOT NULL DEFAULT 0 + )" + ); + $db->exec("ALTER TABLE `lti_resource_links` ADD INDEX (`deployment_id`)"); + + //Migrate the contents of lti_deployments: + $db->exec( + "INSERT INTO `lti_resource_links` (`deployment_id`, `course_id`, `position`, `mkdate`, `chdate`) + SELECT `id`, `course_id`, `position`, `mkdate`, `chdate` FROM `lti_deployments`" + ); + + //Remove columns from lti_deployments: + $db->exec("ALTER TABLE `lti_deployments` DROP COLUMN `course_id`, DROP COLUMN `position`"); + } + + protected function down() + { + $db = DBManager::get(); + + //Add columns to lti_deployments: + $db->exec( + "ALTER TABLE `lti_deployments` + ADD COLUMN `course_id` CHAR(32) NOT NULL, + ADD COLUMN `position` INT(11) NOT NULL DEFAULT 0" + ); + + //Migrate the content of lti_resource_links: + $db->exec( + "UPDATE `lti_deployments` JOIN `lti_resource_links` + ON `lti_deployments`.`id` = `lti_resource_links`.`deployment_id` + SET + `lti_deployments`.`course_id` = `lti_resource_links`.`course_id`, + `lti_deployments`.`position` = `lti_resource_links`.`position`" + ); + + //Remove the lti_resource_links table: + $db->exec("DROP TABLE `lti_resource_links`"); + } +} |
