Commit aeab7cd8 authored by Romain Loth's avatar Romain Loth

sql toolbox examples for maintenance operations

parent 653ecbdd
UPDATE keywords
JOIN (
SELECT kwid, count(uid) AS n FROM sch_kw GROUP BY kwid
) AS mycounts ON keywords.kwid = mycounts.kwid
SET occs = mycounts.n ;
USE comex shared;
-- 1) setting legacy status itself
UPDATE scholars
SET record_status = 'legacy'
WHERE old_itemid IS NOT NULL ; -- or any needed subset criterion
UPDATE scholars
SET valid_date = CURDATE() + INTERVAL 3 MONTH
WHERE old_itemid IS NOT NULL ; -- here the same criterion as before
-- 2) preparing a batch of secret return tokens
INSERT INTO legacy_temp_rettoks
SELECT luid, UUID() FROM scholars
WHERE record_status = "legacy" AND valid_date > CURDATE();
-- 3) outputing all the links to send by mailing list
SET @server_name = 'www.communityexplorer.org' ;
SET @page_route = '/services/user/claim_profile/?token=' ;
SELECT
email,
CONCAT('https://', @server_name, @page_route, rettok) AS link
FROM legacy_temp_rettoks
JOIN scholars
ON scholars.luid = legacy_temp_rettoks.luid ;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment