    [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

  {(s/optional-key :after-load) [CallbackFnSchema]
   (s/optional-key :before-save) [CallbackFnSchema]})

;; a private key for a cassandra table
;; the first entry may itself be a vector, representing
;; a compound partition key
(s/defschema KeySchema

;; a single column
(s/defschema SecondaryKeySchema
  s/Keyword)

;; just map parent fidles to child fields for now
;; :foreign-key and :parent-entity-key will be
;; included by default
(s/defschema DenormalizeSchema
  {s/Keyword s/Keyword})

;; a Relationship allows fields from a parent Entity or
;; one of its index tables to be
;; denormalized to records of a child Entity. 1-1 and 1-many
;; relationships are supported and large child sets are also
;; supported
(s/defschema RelationshipSchema
  {;; target Entity var - will be dynamically deref'd
   :target s/Symbol
   ;; the foreign key which must have the corresponding components
   ;; in the same order as the parent primary key
   :foreign-key KeySchema
   ;; the fields to be denormalized
   :denormalize DenormalizeSchema})

;; basic table schema shared by primary, secondary
;; unique-key and lookup tables
(s/defschema TableSchema
  {:name s/Keyword
   :key KeySchema
   (s/optional-key :relationships) [RelationshipSchema]})

;; the :key is the primary-key of the table, which may
;; have a compound parition key [[pk1 pk2] ck1 ck2]
