data-store: update command_parameter schema and create new migration to fix missing placeholders

This commit is contained in:
Mike Jackson 2017-05-25 08:30:15 +02:00 committed by Roman Volosovskyi
parent 8a3b7372ab
commit 561e0fe77a
4 changed files with 64 additions and 3 deletions

View File

@ -110,7 +110,7 @@
(filter (fn [[_ c]] (:global-command c)))
(map (fn [[id {:keys [global-command]}]]
[(keyword id) (-> global-command
(update :params vals)
(update :params (comp vec vals))
(assoc :bot id
:type :command))]))
(into {}))

View File

@ -6,7 +6,8 @@
[status-im.data-store.realm.schemas.account.v5.core :as v5]
[status-im.data-store.realm.schemas.account.v6.core :as v6]
[status-im.data-store.realm.schemas.account.v7.core :as v7]
[status-im.data-store.realm.schemas.account.v8.core :as v8]))
[status-im.data-store.realm.schemas.account.v8.core :as v8]
[status-im.data-store.realm.schemas.account.v9.core :as v9]))
; put schemas ordered by version
(def schemas [{:schema v1/schema
@ -32,4 +33,7 @@
:migration v7/migration}
{:schema v8/schema
:schemaVersion 8
:migration v8/migration}])
:migration v8/migration}
{:schema v9/schema
:schemaVersion 9
:migration v9/migration}])

View File

@ -0,0 +1,8 @@
(ns status-im.data-store.realm.schemas.account.v9.command-parameter
(:require [taoensso.timbre :as log]))
(def schema {:name :command-parameter
:properties {:name {:type :string}
:type {:type :string}
:placeholder {:type :string
:optional true}}})

View File

@ -0,0 +1,49 @@
(ns status-im.data-store.realm.schemas.account.v9.core
(:require [status-im.data-store.realm.schemas.account.v4.chat :as chat]
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v6.command :as command]
[status-im.data-store.realm.schemas.account.v9.command-parameter :as command-parameter]
[status-im.data-store.realm.schemas.account.v7.contact :as contact]
[status-im.data-store.realm.schemas.account.v1.discover :as discover]
[status-im.data-store.realm.schemas.account.v1.kv-store :as kv-store]
[status-im.data-store.realm.schemas.account.v4.message :as message]
[status-im.data-store.realm.schemas.account.v7.pending-message :as pending-message]
[status-im.data-store.realm.schemas.account.v1.processed-message :as processed-message]
[status-im.data-store.realm.schemas.account.v1.request :as request]
[status-im.data-store.realm.schemas.account.v1.tag :as tag]
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
[status-im.data-store.realm.schemas.account.v5.contact-group :as contact-group]
[status-im.data-store.realm.schemas.account.v5.group-contact :as group-contact]
[status-im.data-store.realm.schemas.account.v8.local-storage :as local-storage]
[taoensso.timbre :as log]))
(def schema [chat/schema
chat-contact/schema
command/schema
command-parameter/schema
contact/schema
discover/schema
kv-store/schema
message/schema
pending-message/schema
processed-message/schema
request/schema
tag/schema
user-status/schema
contact-group/schema
group-contact/schema
local-storage/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v8 account database: " old-realm new-realm)
(let [new-commands (.objects new-realm "command")]
(dotimes [i (.-length new-commands)]
(let [command (aget new-commands i)
command-name (aget command "name")
command-title (aget command "title")]
(cond
(and (= command-name "global") (= command-title "Browser"))
(aset command "params" 0 "placeholder" "URL")
(= command-name "location")
(aset command "params" 0 "placeholder" "Address"))))))