Skip to content

Instantly share code, notes, and snippets.

@magnars
Last active February 11, 2019 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magnars/5e36af346c3d6a47cf0c8e84252386b5 to your computer and use it in GitHub Desktop.
Save magnars/5e36af346c3d6a47cf0c8e84252386b5 to your computer and use it in GitHub Desktop.
Suppress datomic transactions to prod from dev
(defn suppress-datomic-transactions-to-prod [config]
(when (str/starts-with? (:datomic-uri config) "datomic:ddb://")
(println "Warning! Suppressing transactions to production datomic from dev environment. Check your config.")
(let [the-conn (d/connect (:datomic-uri config))]
(alter-var-root (var datomic.api/transact)
(fn [transact]
(fn [conn txs]
(if (= conn the-conn)
(do (log/warn "Suppressed datomic transaction to production.")
(let [db (d/db conn)] (future {:db-after db :db-before db :tx-data nil})))
(transact conn txs))))))))
@stuarthalloway
Copy link

SQL and Cassndra users will be disappointed with these semantics. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment