      (with {:replication {:class "SimpleStrategy" :replication_factor 1}})))
   (info (format "connecting to keyspace %s" keyspace))
   (use-keyspace cluster keyspace)
-  (when-not (describe-table cluster keyspace :t_attr)
-    (warn "creating table t_attr")
-    (create-table
-     cluster :t_attr
-     (if-not-exists)
-     (column-definitions {:key :uuid :name :varchar :bucket :bigint :slot :int :data :blob :primary-key [[:key :name :bucket] :slot]})
-     (with {:compaction {:class "LeveledCompactionStrategy" :sstable_size_in_mb "256"}})))
+  (dotimes [m 12]
+    (let [colfam (t-attr-colfam (+ 1 m))]
+      (when-not (describe-table cluster keyspace colfam)
+        (warn (format "creating table %s" colfam)
+              (create-table
+               cluster colfam
+               (if-not-exists)
+               (column-definitions {:key :uuid :name :varchar :bucket :bigint :slot :int :data :blob :primary-key [[:key :name :bucket] :slot]})
+               (with {:compaction {:class "LeveledCompactionStrategy" :sstable_size_in_mb "256"}}))))))
   (when-not (describe-table cluster keyspace :k_attr)
     (warn "creating table k_attr")
     (create-table


(defn fmt-del-tattr [data]
  (if (contains? data :time)
    (let [[bucket slot] (decode-time (:time data))]
      [(delete-query
        :t_attr
        (where [[= :key (:key data)]
                [= :name (:name data)]
                [= :bucket bucket]

  (let [time (from-long (* 1000 time-in-sec))
        bucket (quot (to-long (date-time (year time) (month time) (day time))) 1000)
        slot (- time-in-sec bucket)]
    [(month time) bucket slot]))

(defn encode-time [bucket slot]
  (+ bucket slot))

(defn t-attr-colfam [month]
  (keyword (format "t_attr_%02d" month)))

(defn use-attr-schema [cluster keyspace]
  (when-not (describe-keyspace cluster keyspace)
