DROP PROCEDURE IF EXISTS `archive_user`;
DELIMITER ;;
CREATE PROCEDURE `archive_user` (
    IN p_user_id INT
)
proc:BEGIN
    -- should check if admin
    IF (SELECT COUNT(user_id) FROM users WHERE user_id = p_user_id) = 0 OR p_user_id IS NULL THEN
        SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'archive_user: User does not exist';
        LEAVE proc;
    END IF;
    INSERT INTO archived_users SELECT * FROM users WHERE user_id = p_user_id;
    DELETE FROM users WHERE user_id = p_user_id;
    SELECT 0 AS 'status', 'archive_user' AS 'proc';
END ;;
DELIMITER ;
