Last active
August 29, 2015 14:21
-
-
Save buckett/ccf3bc423e214806831e to your computer and use it in GitHub Desktop.
Delete all MyWorkspace sites from a Sakai deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Deletes all user myworkspaces we can find. | |
-- Matthew Buckett | |
BEGIN WORK; | |
CREATE TEMPORARY TABLE delete_ids ( | |
id varchar(99) UNIQUE | |
); | |
-- If you want to be more brutal you can exlude the join to sakai_user_id_map and just look for all IDs that start with ~ | |
INSERT INTO delete_ids SELECT site_id from SAKAI_SITE where site_id in (SELECT concat("~",user_id) FROM SAKAI_USER_ID_MAP where user_id != eid) FOR UPDATE; | |
DELETE s FROM SAKAI_SITE_TOOL_PROPERTY s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_TOOL_PROPERTY FROM DUAL; | |
DELETE s FROM SAKAI_SITE_PAGE_PROPERTY s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_PAGE_PROPERTY FROM DUAL; | |
DELETE s FROM SAKAI_SITE_GROUP_PROPERTY s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_GROUP_PROPERTY FROM DUAL; | |
DELETE s FROM SAKAI_SITE_USER s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_USER FROM DUAL; | |
DELETE s FROM SAKAI_SITE_TOOL s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_TOOL FROM DUAL; | |
DELETE s FROM SAKAI_SITE_PAGE s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_PAGE FROM DUAL; | |
DELETE s FROM SAKAI_SITE_PROPERTY s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_PROPERTY FROM DUAL; | |
DELETE s FROM SAKAI_SITE_GROUP s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_GROUP FROM DUAL; | |
DELETE s FROM SAKAI_SITE s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE FROM DUAL; | |
DELETE s FROM SAKAI_SITE_USER s, delete_ids WHERE site_id = delete_ids.id; | |
SELECT ROW_COUNT() as SAKAI_SITE_USER FROM DUAL; | |
SELECT site_id as "Remaining User Sites" from SAKAI_SITE where site_id like '~%'; | |
COMMIT WORK; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment