anchor.diff:  ;; 'cat not 'pgj_model.cat).  In the mean time we have this...  If
   ;; you don't know anything about search paths this should do the job,
   ;; and if you do you can look after yourself.
  -(defparameter *default-search-path* (format nil "~A,public" (to-sql-name *pgj-schema*))
  +(defvar *default-search-path* (format nil "~A,public" (to-sql-name *pgj-schema*))
     "The default value used by ALTER-ROLE-SET-SEARCH-PATH.")
   
   (defun alter-role-set-search-path (user &optional (search-path *default-search-path*))
  
positive.code: by settings in your ~/.psqlrc file.  See also the Postgres
  documentation on search paths and settings."
    (query (format nil "ALTER ROLE ~A SET search_path TO ~A" user search-path)))
  
  (defun create-model (model &optional (parameters (make-model-parameters model)))
    "Create the PostgreSQL tables and indexes for Postgre JSON
  persistence model MODEL, a symbol.  Uses the various values in the
  PARAMETERS CLOS object to customize the model.  Should only be called
  once per model.  Returns MODEL."
    (let* ((base model)
           (base-old (sym-suffix base "old"))
           (index (sym-suffix base "gin"))
           (index-old (sym-suffix base "old-gin")))
      (with-model-transaction (create-model)
        (create-base-table base parameters)
        (create-old-table base-old parameters)
        (create-gin-index index base parameters)
        (create-gin-index index-old base-old parameters)
        (unless (eq *meta-model* model)
          (insert-model-parameters parameters)))
      model))
  
  (defun model-exists-p (model)
    "Does MODEL, a symbol, exist in our backend?"
    (if (fetch *meta-model* (symbol->json model)) t nil))
  
  (defun ensure-model (model &optional (parameters (make-model-parameters model)))
    "Call CREATE-MODEL with MODEL and PARAMETERS as arguments, unless MODEL
  already exists."
    (unless (model-exists-p model)
      (create-model model parameters)))
  
  (defun all-models ()
    "Return a list of all models in the backend."
    (mapcar #'json->symbol (keys *meta-model*)))
  
  (defun drop-backend ()
    "Drop the backend (that is the PostgreSQL schema *PGJ-SCHEMA*) in
  the database Postmodern is currently connected to.  This will
  irrevocably delete ALL your data in ALL your models so it uses
  a RESTART-CASE to guard against human error."
    (flet ((drop ()
             (with-model-transaction (drop-backend)
               (drop-db-schema-cascade *pgj-schema*))))
      (when (backend-exists-p)
        (let ((attempted-to (format nil "DROP all models' data(!) in schema: ~A" *pgj-schema*)))
          (restart-case (error 'database-safety-net
                               :attempted-to attempted-to
                               :suggestion "Pick an appropriate restart")
            (cancel () :report "Leave this schema alone." (return-from drop-backend nil))
            (really-do-it () :report "I really want to drop ALL data in ALL models(!)" (drop)))))))
  
  (defun drop-model (model)
    "Drop model MODEL.  This will irrevocably delete all data associated
  with the model so it uses a RESTART-CASE to guard against human
  error."
    (flet ((drop ()
             (with-model-transaction (drop-model)
               (excise *meta-model* (symbol->json model))
               (drop-db-table-cascade model *pgj-schema*)
               (drop-db-table-cascade (sym t model "-old") *pgj-schema*))))
      (restart-case (error 'database-safety-net
                           :attempted-to (format nil "DROP model ~A" model)
                           :suggestion "Pick an appropriate restart")
        (cancel () :report "Leave this model alone." (return-from drop-model nil))
        (really-do-it () :report "I really want to DROP this model" (drop)))))
  
  (defun flush-prepared-queries ()
    "If you get a 'Database error 26000: prepared statement ... does not
  exist error' while mucking around at the REPL, call this.  A similar
  error in production code should be investigated."
    (setf *query-functions* (make-hash-table :test #'equal)))
  
negative.code: (in-package :postgres-json)
  
  ;;;; Implementation
  
  (defun create-pgj-schema ()
    "Create the schema *PGJ-SCHEMA* and other backend objects needed to
  house user created PostgreSQL JSON persistence models.  Call just once
  in a given PostgreSQL database."
    (maybe-transaction (create-backend read-committed-rw)
      (pomo:create-schema *pgj-schema*)
      (create-db-sequence *pgj-sequence* *pgj-schema*)
      *pgj-schema*))
  
  (defun pgj-schema-exists-p ()
    "Does the backend *PGJ-SCHEMA* exist?"
    (pomo:schema-exist-p *pgj-schema*))
  
  (defun ensure-pgj-schema ()
    "Call CREATE-PGJ-SCHEMA unless the Postgres *PGJ-SCHEMA* already exists."
    (unless (pgj-schema-exists-p)
      (create-pgj-schema)))
  
  ;;;; Interface
  
  (defvar *postmodern-connection* nil
    "Set this to a list congruent with the parameters expected by
  POSTMODERN:CONNECT-TOPLEVEL, for use by the testing and example
  code.")
  
  (defun ensure-top-level-connection (&optional (connect-spec *postmodern-connection*))
    "Ensure a Postmodern top level connection is active by applying the
  contents of the list CONNECT-SPEC to POMO:CONNECT-TOPLEVEL."
    (unless connect-spec
      (error "Try setting POSTGRES-JSON:*POSTMODERN-CONNECTION* to a
  list congruent with the parameters expected by POSTMODERN:CONNECT-TOPLEVEL.
  For example: '\(\"mydb\", \"myusername\", \"\", \"localhost\"\).
  This connection list is used by the example and testing code."))
    (unless (and pomo:*database* (pomo:connected-p pomo:*database*))
      (apply #'pomo:connect-toplevel connect-spec)))
  
  (defun drop-pgj-schema ()
    "Drop the entire Postgres schema *PGJ-SCHEMA* in the database
  Postmodern is currently connected to.  This will irrevocably delete
  ALL your data in ALL your models so it uses a RESTART-CASE to guard
  against human error."
    (flet ((drop ()
             (maybe-transaction (drop-backend read-committed-rw)
               (drop-db-schema-cascade *pgj-schema*))))
      (when (pgj-schema-exists-p)
        (let ((attempted-to (format nil "DROP all models' data(!) in schema: ~A" *pgj-schema*)))
          (restart-case (error 'database-safety-net
                               :attempted-to attempted-to
                               :suggestion "Pick an appropriate restart")
            (cancel () :report "Leave this schema alone." (return-from drop-pgj-schema nil))
            (really-do-it () :report "I really want to drop ALL data in ALL models(!)" (drop)))))))
  
  ;; I _hate_ this search_path nonsense and have largely avoided it by
  ;; using fully qualified relation names.  But DEFINE-MODEL-QUERY
  