    [cats.labs.manifold :refer [deferred-context]]
    [schema.core :as s]
    [clj-time.core :as t]
+   [er-cassandra.util.vector :as v]
    [er-cassandra.key :as k]))
 
 (s/defschema CallbackFnSchema

;; delete with a secondary index from seocondary and lookup tables
;; TODO use the :entity-key to delete stale secondary and lookup records
(s/defschema PrimaryTableSchema
  {:name s/Keyword
   :key KeySchema
   (s/optional-key :entity-key) SecondaryKeySchema})

;; some of the (non-partition) columns in a lookup-table
;; key may be collections... these will be expanded to the

  {(s/optional-key :collections) {s/Keyword
                                  (s/pred #{:list :set :map})}})

(s/defschema EntityKeySchema
  {(s/optional-key :has-entity-key?) s/Bool})

;; unique-key tables are lookup tables with a unique
;; constraint on the key, enforced with an LWT
(s/defschema UniqueKeyTableSchema
  (merge TableSchema
         CollectionKeysSchema
         EntityKeySchema))

;; secondary tables contain all columns from the primary
;; table, with a different primary key.
;; secondary and lookup tables may be materialized views,
;; which will be used for query but won't be upserted to
(s/defschema SecondaryTableSchema
  (merge TableSchema
         EntityKeySchema
         {(s/optional-key :view?) s/Bool}))

;; lookup tables contain columns from the uberkey and
;; a lookup key, plus any additional with-columns
(s/defschema LookupTableSchema
  (merge SecondaryTableSchema
         CollectionKeysSchema
