From 25152f605495fbd3e3bdae555f8ca142490a6d65 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Thu, 25 Jan 2018 23:38:59 +0100 Subject: [PATCH] Add a restart-case for interactive debugging. When dealing with MATERIALIZING VIEWS test cases and failing in the middle of them, as it happens when fixing bugs, then it was tedious (to say the least) to clean-up manually the view each time. That said, for end-users, doing it automatically would risk cleaning-up the wrong view definition if they had a typo in their pgloader command, say. Common Lisp helps a lot here: we simply create a restart that is only available interactively for the developers of pgloader! --- src/sources/mysql/mysql-schema.lisp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sources/mysql/mysql-schema.lisp b/src/sources/mysql/mysql-schema.lisp index f0ef665..c8d0715 100644 --- a/src/sources/mysql/mysql-schema.lisp +++ b/src/sources/mysql/mysql-schema.lisp @@ -22,7 +22,20 @@ for sql = (format nil "CREATE VIEW ~a AS ~a" name def) do (log-message :info "MySQL: ~a" sql) - (mysql-query sql)))))) + #+pgloader-image + (mysql-query sql) + #-pgloader-image + (restart-case + (mysql-query sql) + (use-existing-view () + :report "Use the already existing view and continue" + nil) + (replace-view () + :report "Replace the view with the one from pgloader's command" + (let ((drop-sql (format nil "DROP VIEW ~a;" name))) + (log-message :info "MySQL: ~a" drop-sql) + (mysql-query drop-sql) + (mysql-query sql))))))))) (defun drop-my-views (views-alist) "See `create-my-views' for VIEWS-ALIST description. This time we DROP the