Skip to content

Instantly share code, notes, and snippets.

@lancepantz
Created June 18, 2010 02:17
Show Gist options
  • Save lancepantz/443115 to your computer and use it in GitHub Desktop.
Save lancepantz/443115 to your computer and use it in GitHub Desktop.
(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