Created
June 18, 2010 02:17
-
-
Save lancepantz/443115 to your computer and use it in GitHub Desktop.
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
(defn revert [id attrs opts] | |
(sql/with-connection rev-log | |
(let [id (Integer/parseInt (last (re-split #"-" id))) | |
result (sql/with-query-results result | |
["UPDATE revisions | |
SET reverted_by = nextval('revision_id_seq'::regclass) | |
WHERE id=? | |
AND reverted_by IS NULL | |
returning reverted_by AS revision;" | |
id] | |
(first result))] | |
(if result | |
(log attrs opts) | |
(throw (Exception. "revision already reverted")) | |
)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment