         SET NEW.sortorder = 1;
     END IF;
 END;
-$$
-DELIMITER ;
 
 DROP TRIGGER IF EXISTS monad_page_insert_after;
-DELIMITER $$
 CREATE TRIGGER monad_page_insert_after AFTER INSERT ON monad_page
 FOR EACH ROW
 BEGIN

    UNTIL @parent IS NULL END REPEAT;
    RETURN @slug;
END;
$$
DELIMITER ;


DROP TRIGGER IF EXISTS monad_page_update_before;
DELIMITER $$
CREATE TRIGGER monad_page_update_before BEFORE UPDATE ON monad_page
FOR EACH ROW
BEGIN
    SET NEW.datemodified = NOW();
END;
$$
DELIMITER ;

DROP TRIGGER IF EXISTS monad_query_insert_before;
DELIMITER $$
CREATE TRIGGER monad_query_insert_before BEFORE INSERT ON monad_query
FOR EACH ROW
BEGIN
    SET NEW.checksum = md5(CONCAT(NEW.owner, NEW.`session`, NEW.querysql, NOW()));
END;
$$
DELIMITER ;

DROP TRIGGER IF EXISTS monad_page_insert_before;
DELIMITER $$
CREATE TRIGGER monad_page_insert_before BEFORE INSERT ON monad_page
FOR EACH ROW
BEGIN


-- {{{ v0.23.1

CREATE TABLE monad_page (
    id bigint UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
    parent bigint UNSIGNED,
