Wiki

Clone wiki

MOODECx / SQL Script Certificate

SQL script - Certificate

As soon as the migration process from Moodle 2.9 to 3.3 is finished and before performing another activity, you must apply the following script that transfers the data from the Moodeccertificate plugin to the Certificate plugin.

#!sql

-- Ajout du champs teacher dans la table mdl_moodeccertificate
ALTER TABLE mdl_moodeccertificate ADD teacher VARCHAR(60) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER introformat;
-- Renommer la colonne "moodeccertificatetype" pour "certificatetype" de a table "mdl_moodeccertificate"
ALTER TABLE mdl_moodeccertificate CHANGE moodeccertificatetype certificatetype VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
-- Import des données de "mdl_moodeccertificate" vers "mdl_certificate"
INSERT INTO mdl_certificate SELECT * FROM mdl_moodeccertificate;
-- Suppression de la table "mdl_moodeccertificate"
DROP TABLE mdl_moodeccertificate;

-- Renommer la colonne "moodeccertificateid" pour "certificateid" de la table "mdl_moodeccertificate_issues"
ALTER TABLE mdl_moodeccertificate_issues CHANGE moodeccertificateid certificateid BIGINT(10) NOT NULL DEFAULT '0';
-- Import des données de "mdl_moodeccertificate_issues" vers "mdl_certificate_issues"
INSERT INTO mdl_certificate_issues SELECT * FROM mdl_moodeccertificate_issues;
-- Suppression de la table "mdl_moodeccertificate_issues"
DROP TABLE mdl_moodeccertificate_issues;

-- CHANGE ID /!\ Changer/Vérifier les 'ID', puis décommenter
SET @moodeccertificateID = (SELECT id FROM mdl_modules WHERE name = 'moodeccertificate');
SET @tempID = 9999;
UPDATE mdl_modules SET id = @tempID WHERE mdl_modules.id = @moodeccertificateID AND name = 'moodeccertificate';
SET @certificateID = (SELECT id FROM mdl_modules WHERE name = 'certificate');
UPDATE mdl_modules SET id = @moodeccertificateID WHERE mdl_modules.id = @certificateID AND name = 'certificate';
UPDATE mdl_modules SET id = @certificateID WHERE mdl_modules.id = @tempID AND name = 'moodeccertificate';

Updated