summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/weepinbell/migration.clj18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/weepinbell/migration.clj b/src/weepinbell/migration.clj
index 0667bc3..4883b99 100644
--- a/src/weepinbell/migration.clj
+++ b/src/weepinbell/migration.clj
@@ -1,8 +1,13 @@
(ns weepinbell.migration
(:require [weepinbell.storage.sqlite :as sqlite]
- [weepinbell.storage.edn-storage :as edns]))
+ [weepinbell.storage.edn-storage :as edns])
+ (:import [org.sqlite SQLiteException]))
-(defn edn->sqlite [edn-file sqlite-db]
+(defn edn->sqlite
+ "Given a EDN file and a SQLite DB path, migrate data from that
+ edn file to SQLite DB. It appends data to DB so the destination
+ db can be empty or it can has some data."
+ [edn-file sqlite-db]
{:pre [(some? edn-file) (some? sqlite-db)]}
(let [ds (sqlite/make-datasource sqlite-db)]
(sqlite/create-tables ds)
@@ -11,5 +16,12 @@
(doseq [wm wms]
(let [id (get-in wm [:webmention :id])]
(println "Appending webmention" id "to database")
- (sqlite/insert-webmention ds wm)))))
+ (try
+ (sqlite/insert-webmention ds wm)
+ (catch SQLiteException e
+ (println "Something wrong with data or database")
+ (println (.getMessage e)))
+ (catch Exception e
+ (println "Something unexpected happened.")
+ (println (.getMessage e))))))))
(println "Done")))