 CREATE FUNCTION page_version_before() RETURNS trigger AS $$
     DECLARE
         _aid int;
-        _now timestamp := current_timestamp;
         _sta status;
     BEGIN
         -- Actually, archived status should not be allowed for new items (INSERTs) after initial setup of DB

            -- Create new version
            INSERT INTO
                version
                (name, entity_id, title, teaser, main, aside, account_id, status, page_id)
            VALUES
                (_row.name, _row.entity_id, _row.title, _row.teaser, _row.main, _row.aside, _row.account_id, _row.status, _row.id);

            -- Update page status
            UPDATE


        INSERT INTO
            version
            (name, entity_id, page_id, teaser, main, aside, status, timestamp)
        SELECT
            name,
            entity_id,
            id AS page_id,
            teaser,
            main,
            aside,
            status,
            timestamp
        FROM
            page
        ORDER BY
