把Umbraco user刪掉並且把本來屬於此user的資料(例如audit trail)指向admin(userid 0)
Last active
June 3, 2017 08:53
-
-
Save alantsai/5137e3e77321462c9356 to your computer and use it in GitHub Desktop.
#Umbraco #sql delete user by user Id(用使用者Id刪除使用者)
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
DECLARE @userId int; | |
SET @userId = $userId; -- set desire delete user Id | |
-- don't nuke these records, but can re-assign back to "admin" master user (or whoever else) | |
SELECT * from umbracoNode WHERE nodeUser = @userId | |
SELECT * from cmsDocument WHERE documentUser = @userId | |
-- these can be nuked | |
SELECT * FROM umbracoLog WHERE userId = @userId | |
SELECT * FROM umbracoUser2App WHERE [user] = @userId | |
-- 加入客制table | |
--單位 | |
SELECT * FROM UmbracoUser2Department WHERE UserId = @userId | |
SELECT * FROM umbracoUser2Group WHERE UserId = @userId | |
SELECT * FROM umbracoUserParm WHERE UserId = @userId | |
-- 結束加入客制table | |
SELECT * FROM umbracoUser WHERE id = @userId |
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
DECLARE @userId int; | |
SET @userId = $userId; -- set desire delete user Id | |
-- don't nuke these records, but can re-assign back to "admin" master user (or whoever else) | |
UPDATE umbracoNode SET nodeUser = 0 WHERE nodeUser = @userId | |
UPDATE cmsDocument SET documentUser = 0 WHERE documentUser = @userId | |
-- these can be nuked | |
DELETE FROM umbracoLog WHERE userId = @userId | |
DELETE FROM umbracoUser2App WHERE [user] = @userId | |
DELETE FROM umbracoUserLogins WHERE userID = @userId | |
-- 加入客制table | |
--單位 | |
DELETE FROM UmbracoUser2Department WHERE UserId = @userId | |
Delete FROM umbracoUser2Group WHERE UserId = @userId | |
Delete FROM umbracoUserParm WHERE UserId = @userId | |
-- 結束加入客制table | |
DELETE FROM umbracoUser WHERE id = @userId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment