change realm schemas directory layout
the purpose of this change is to avoid the kind of mistakes that happened in the past were copy/pasting imports led to wrong migrations that went unnoticed it will also make it easier to do migrations in the future as the different versions of the same schemas are grouped together in the same file and past migrations are grouped in the same file as well so previous helper functions can be reused Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
a4c95ff734
commit
b8d250ba30
|
@ -0,0 +1,25 @@
|
|||
(ns status-im.data-store.realm.schemas.account.browser)
|
||||
|
||||
(def v1 {:name :browser
|
||||
:primaryKey :browser-id
|
||||
:properties {:browser-id :string
|
||||
:name :string
|
||||
:timestamp :int
|
||||
:dapp? {:type :bool
|
||||
:default false}
|
||||
:url {:type :string
|
||||
:optional true}
|
||||
:contact {:type :string
|
||||
:optional true}}})
|
||||
|
||||
(def v8 {:name :browser
|
||||
:primaryKey :browser-id
|
||||
:properties {:browser-id :string
|
||||
:name :string
|
||||
:timestamp :int
|
||||
:dapp? {:type :bool
|
||||
:default false}
|
||||
:history-index {:type :int
|
||||
:optional true}
|
||||
:history {:type "string[]"
|
||||
:optional true}}})
|
|
@ -0,0 +1,94 @@
|
|||
(ns status-im.data-store.realm.schemas.account.chat
|
||||
(:require [status-im.ui.components.styles :refer [default-chat-color]]))
|
||||
|
||||
(def v1 {:name :chat
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:name :string
|
||||
:color {:type :string
|
||||
:default default-chat-color}
|
||||
:group-chat {:type :bool
|
||||
:indexed true}
|
||||
:group-admin {:type :string
|
||||
:optional true}
|
||||
:is-active :bool
|
||||
:timestamp :int
|
||||
:contacts {:type "string[]"}
|
||||
:removed-at {:type :int
|
||||
:optional true}
|
||||
:removed-from-at {:type :int
|
||||
:optional true}
|
||||
:added-to-at {:type :int
|
||||
:optional true}
|
||||
:updated-at {:type :int
|
||||
:optional true}
|
||||
:message-overhead {:type :int
|
||||
:default 0}
|
||||
:contact-info {:type :string
|
||||
:optional true}
|
||||
:debug? {:type :bool
|
||||
:default false}
|
||||
:public? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(def v3 {:name :chat
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:name :string
|
||||
:color {:type :string
|
||||
:default default-chat-color}
|
||||
:group-chat {:type :bool
|
||||
:indexed true}
|
||||
:group-admin {:type :string
|
||||
:optional true}
|
||||
:is-active :bool
|
||||
:timestamp :int
|
||||
:contacts {:type "string[]"}
|
||||
:removed-at {:type :int
|
||||
:optional true}
|
||||
:removed-from-at {:type :int
|
||||
:optional true}
|
||||
:deleted-at-clock-value {:type :int
|
||||
:optional true}
|
||||
:added-to-at {:type :int
|
||||
:optional true}
|
||||
:updated-at {:type :int
|
||||
:optional true}
|
||||
:message-overhead {:type :int
|
||||
:default 0}
|
||||
:contact-info {:type :string
|
||||
:optional true}
|
||||
:debug? {:type :bool
|
||||
:default false}
|
||||
:public? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(def v5 {:name :chat
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:name :string
|
||||
:color {:type :string
|
||||
:default default-chat-color}
|
||||
:group-chat {:type :bool
|
||||
:indexed true}
|
||||
:group-admin {:type :string
|
||||
:optional true}
|
||||
:is-active :bool
|
||||
:timestamp :int
|
||||
:contacts {:type "string[]"}
|
||||
:removed-at {:type :int
|
||||
:optional true}
|
||||
:removed-from-at {:type :int
|
||||
:optional true}
|
||||
:deleted-at-clock-value {:type :int
|
||||
:optional true}
|
||||
:added-to-at {:type :int
|
||||
:optional true}
|
||||
:updated-at {:type :int
|
||||
:optional true}
|
||||
:message-overhead {:type :int
|
||||
:default 0}
|
||||
:debug? {:type :bool
|
||||
:default false}
|
||||
:public? {:type :bool
|
||||
:default false}}})
|
|
@ -0,0 +1,27 @@
|
|||
(ns status-im.data-store.realm.schemas.account.contact)
|
||||
|
||||
(def v1 {:name :contact
|
||||
:primaryKey :whisper-identity
|
||||
:properties {:address {:type :string :optional true}
|
||||
:whisper-identity :string
|
||||
:name {:type :string :optional true}
|
||||
:photo-path {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-online {:type :int :default 0}
|
||||
:pending? {:type :bool :default false}
|
||||
:hide-contact? {:type :bool :default false}
|
||||
:status {:type :string :optional true}
|
||||
:fcm-token {:type :string :optional true}
|
||||
:description {:type :string :optional true}
|
||||
:public-key {:type :string
|
||||
:optional true}
|
||||
:dapp? {:type :bool
|
||||
:default false}
|
||||
:dapp-url {:type :string
|
||||
:optional true}
|
||||
:bot-url {:type :string
|
||||
:optional true}
|
||||
:dapp-hash {:type :int
|
||||
:optional true}
|
||||
:debug? {:type :bool
|
||||
:default false}}})
|
|
@ -1,50 +1,158 @@
|
|||
(ns status-im.data-store.realm.schemas.account.core
|
||||
(:require
|
||||
[status-im.data-store.realm.schemas.account.v1.core :as v1]
|
||||
[status-im.data-store.realm.schemas.account.v2.core :as v2]
|
||||
[status-im.data-store.realm.schemas.account.v3.core :as v3]
|
||||
[status-im.data-store.realm.schemas.account.v4.core :as v4]
|
||||
[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.v9.core :as v9]
|
||||
[status-im.data-store.realm.schemas.account.v10.core :as v10]
|
||||
[status-im.data-store.realm.schemas.account.v11.core :as v11]))
|
||||
(:require [status-im.data-store.realm.schemas.account.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.browser :as browser]
|
||||
[status-im.data-store.realm.schemas.account.dapp-permissions :as dapp-permissions]
|
||||
[status-im.data-store.realm.schemas.account.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.migrations :as migrations]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
;; TODO(oskarth): Add failing test if directory vXX exists but isn't in schemas.
|
||||
(def v1 [chat/v1
|
||||
transport/v1
|
||||
contact/v1
|
||||
message/v1
|
||||
request/v1
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v1])
|
||||
|
||||
(def v2 [chat/v1
|
||||
transport/v1
|
||||
contact/v1
|
||||
message/v1
|
||||
request/v1
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v1])
|
||||
|
||||
(def v3 [chat/v3
|
||||
transport/v1
|
||||
contact/v1
|
||||
message/v1
|
||||
request/v1
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v1])
|
||||
|
||||
(def v4 [chat/v3
|
||||
transport/v4
|
||||
contact/v1
|
||||
message/v1
|
||||
request/v1
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v1])
|
||||
|
||||
(def v5 [chat/v5
|
||||
transport/v4
|
||||
contact/v1
|
||||
message/v1
|
||||
request/v1
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v1])
|
||||
|
||||
(def v6 [chat/v5
|
||||
transport/v6
|
||||
contact/v1
|
||||
message/v1
|
||||
request/v1
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v1])
|
||||
|
||||
(def v7 [chat/v5
|
||||
transport/v6
|
||||
contact/v1
|
||||
message/v7
|
||||
request/v1
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v1])
|
||||
|
||||
(def v8 [chat/v5
|
||||
transport/v6
|
||||
contact/v1
|
||||
message/v7
|
||||
request/v1
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v8])
|
||||
|
||||
(def v9 [chat/v5
|
||||
transport/v6
|
||||
contact/v1
|
||||
message/v7
|
||||
request/v1
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v8
|
||||
dapp-permissions/v9])
|
||||
|
||||
(def v10 [chat/v5
|
||||
transport/v6
|
||||
contact/v1
|
||||
message/v7
|
||||
mailserver/v2
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v8
|
||||
dapp-permissions/v9])
|
||||
|
||||
(def v11 [chat/v5
|
||||
transport/v6
|
||||
contact/v1
|
||||
message/v7
|
||||
mailserver/v11
|
||||
user-status/v1
|
||||
local-storage/v1
|
||||
browser/v8
|
||||
dapp-permissions/v9])
|
||||
|
||||
;; put schemas ordered by version
|
||||
(def schemas [{:schema v1/schema
|
||||
(def schemas [{:schema v1
|
||||
:schemaVersion 1
|
||||
:migration v1/migration}
|
||||
{:schema v2/schema
|
||||
:migration migrations/v1}
|
||||
{:schema v2
|
||||
:schemaVersion 2
|
||||
:migration v2/migration}
|
||||
{:schema v3/schema
|
||||
:migration migrations/v2}
|
||||
{:schema v3
|
||||
:schemaVersion 3
|
||||
:migration v3/migration}
|
||||
{:schema v4/schema
|
||||
:migration migrations/v3}
|
||||
{:schema v4
|
||||
:schemaVersion 4
|
||||
:migration v4/migration}
|
||||
{:schema v5/schema
|
||||
:migration migrations/v4}
|
||||
{:schema v5
|
||||
:schemaVersion 5
|
||||
:migration v5/migration}
|
||||
{:schema v6/schema
|
||||
:migration migrations/v5}
|
||||
{:schema v6
|
||||
:schemaVersion 6
|
||||
:migration v6/migration}
|
||||
{:schema v7/schema
|
||||
:migration migrations/v6}
|
||||
{:schema v7
|
||||
:schemaVersion 7
|
||||
:migration v7/migration}
|
||||
{:schema v8/schema
|
||||
:migration migrations/v7}
|
||||
{:schema v8
|
||||
:schemaVersion 8
|
||||
:migration v8/migration}
|
||||
{:schema v9/schema
|
||||
:migration migrations/v8}
|
||||
{:schema v9
|
||||
:schemaVersion 9
|
||||
:migration v9/migration}
|
||||
{:schema v10/schema
|
||||
:migration migrations/v9}
|
||||
{:schema v10
|
||||
:schemaVersion 10
|
||||
:migration v10/migration}
|
||||
{:schema v11/schema
|
||||
:migration migrations/v10}
|
||||
{:schema v11
|
||||
:schemaVersion 11
|
||||
:migration v11/migration}])
|
||||
:migration migrations/v11}])
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
(ns status-im.data-store.realm.schemas.account.dapp-permissions)
|
||||
|
||||
(def v9 {:name :dapp-permissions
|
||||
:primaryKey :dapp
|
||||
:properties {:dapp :string
|
||||
:permissions {:type "string[]"
|
||||
:optional true}}})
|
|
@ -0,0 +1,7 @@
|
|||
(ns status-im.data-store.realm.schemas.account.local-storage)
|
||||
|
||||
(def v1 {:name :local-storage
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:data {:type :string
|
||||
:default "{}"}}})
|
|
@ -0,0 +1,19 @@
|
|||
(ns status-im.data-store.realm.schemas.account.mailserver)
|
||||
|
||||
(def v2 {:name :mailserver
|
||||
:primaryKey :id
|
||||
:properties {:id :string
|
||||
:name {:type :string}
|
||||
:address {:type :string}
|
||||
:password {:type :string
|
||||
:optional true}
|
||||
:chain {:type :string}}})
|
||||
|
||||
(def v11 {:name :mailserver
|
||||
:primaryKey :id
|
||||
:properties {:id :string
|
||||
:name {:type :string}
|
||||
:address {:type :string}
|
||||
:password {:type :string
|
||||
:optional true}
|
||||
:fleet {:type :string}}})
|
|
@ -0,0 +1,53 @@
|
|||
(ns status-im.data-store.realm.schemas.account.message)
|
||||
|
||||
(def v1 {:name :message
|
||||
:primaryKey :message-id
|
||||
:properties {:message-id :string
|
||||
:from :string
|
||||
:to {:type :string
|
||||
:optional true}
|
||||
:content :string ; TODO make it ArrayBuffer
|
||||
:content-type :string
|
||||
:username {:type :string
|
||||
:optional true}
|
||||
:timestamp :int
|
||||
:chat-id {:type :string
|
||||
:indexed true}
|
||||
:outgoing :bool
|
||||
:retry-count {:type :int
|
||||
:default 0}
|
||||
:message-type {:type :string
|
||||
:optional true}
|
||||
:message-status {:type :string
|
||||
:optional true}
|
||||
:user-statuses {:type :list
|
||||
:objectType :user-status}
|
||||
:clock-value {:type :int
|
||||
:default 0}
|
||||
:show? {:type :bool
|
||||
:default true}}})
|
||||
|
||||
(def v7 {:name :message
|
||||
:primaryKey :message-id
|
||||
:properties {:message-id :string
|
||||
:from :string
|
||||
:to {:type :string
|
||||
:optional true}
|
||||
:content :string ; TODO make it ArrayBuffer
|
||||
:content-type :string
|
||||
:username {:type :string
|
||||
:optional true}
|
||||
:timestamp :int
|
||||
:chat-id {:type :string
|
||||
:indexed true}
|
||||
:outgoing :bool
|
||||
:retry-count {:type :int
|
||||
:default 0}
|
||||
:message-type {:type :string
|
||||
:optional true}
|
||||
:message-status {:type :string
|
||||
:optional true}
|
||||
:clock-value {:type :int
|
||||
:default 0}
|
||||
:show? {:type :bool
|
||||
:default true}}})
|
|
@ -0,0 +1,68 @@
|
|||
(ns status-im.data-store.realm.schemas.account.migrations
|
||||
(:require [taoensso.timbre :as log]
|
||||
[cljs.reader :as reader]))
|
||||
|
||||
(defn v1 [old-realm new-realm]
|
||||
(log/debug "migrating v1 account database: " old-realm new-realm))
|
||||
|
||||
(defn v2 [old-realm new-realm]
|
||||
(log/debug "migrating v2 account database: " old-realm new-realm))
|
||||
|
||||
(defn v3 [old-realm new-realm]
|
||||
(log/debug "migrating v3 account database: " old-realm new-realm))
|
||||
|
||||
(defn v4 [old-realm new-realm]
|
||||
(log/debug "migrating v4 account database: " old-realm new-realm))
|
||||
|
||||
(defn v5 [old-realm new-realm]
|
||||
(log/debug "migrating chats schema v5")
|
||||
(let [chats (.objects new-realm "chat")]
|
||||
(dotimes [i (.-length chats)]
|
||||
(js-delete (aget chats i) "contact-info"))))
|
||||
|
||||
(defn v6 [old-realm new-realm]
|
||||
(log/debug "migrating v6 account database: " old-realm new-realm))
|
||||
|
||||
(defn v7 [old-realm new-realm]
|
||||
(log/debug "migrating messages schema v7")
|
||||
(let [messages (.objects new-realm "message")]
|
||||
(dotimes [i (.-length messages)]
|
||||
(js-delete (aget messages i) "user-statuses"))))
|
||||
|
||||
(defn message-by-id [realm message-id]
|
||||
(some-> realm
|
||||
(.objects "message")
|
||||
(.filtered (str "message-id = \"" message-id "\""))
|
||||
(aget 0)))
|
||||
|
||||
(defn v8 [old-realm new-realm]
|
||||
(log/debug "migrating v8 account database")
|
||||
(let [browsers (.objects new-realm "browser")
|
||||
old-browsers (.objects old-realm "browser")]
|
||||
(dotimes [i (.-length browsers)]
|
||||
(let [browser (aget browsers i)
|
||||
old-browser (aget old-browsers i)
|
||||
url (aget old-browser "url")]
|
||||
(aset browser "history-index" 0)
|
||||
(aset browser "history" (clj->js [url]))))))
|
||||
|
||||
(defn v9 [old-realm new-realm]
|
||||
(log/debug "migrating v9 account database"))
|
||||
|
||||
(defn v10 [old-realm new-realm]
|
||||
(log/debug "migrating v10 account database")
|
||||
(some-> old-realm
|
||||
(.objects "request")
|
||||
(.filtered (str "status = \"answered\""))
|
||||
(.map (fn [request _ _]
|
||||
(let [message-id (aget request "message-id")
|
||||
message (message-by-id new-realm message-id)
|
||||
content (reader/read-string (aget message "content"))
|
||||
new-content (assoc-in content [:params :answered?] true)]
|
||||
(aset message "content" (pr-str new-content)))))))
|
||||
|
||||
(defn v11 [old-realm new-realm]
|
||||
(log/debug "migrating v11 account database")
|
||||
(let [mailservers (.objects new-realm "mailserver")]
|
||||
(dotimes [i (.-length mailservers)]
|
||||
(aset (aget mailservers i) "fleet" "eth.beta"))))
|
|
@ -0,0 +1,8 @@
|
|||
(ns status-im.data-store.realm.schemas.account.request)
|
||||
|
||||
(def v1 {:name :request
|
||||
:properties {:message-id :string
|
||||
:chat-id :string
|
||||
:response :string
|
||||
:status {:type :string
|
||||
:default "open"}}})
|
|
@ -0,0 +1,49 @@
|
|||
(ns status-im.data-store.realm.schemas.account.transport)
|
||||
|
||||
(def v1 {:name :transport
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:ack :string
|
||||
:seen :string
|
||||
:pending-ack :string
|
||||
:pending-send :string
|
||||
:topic :string
|
||||
:sym-key-id {:type :string
|
||||
:optional true}
|
||||
;;TODO (yenda) remove once go implements persistence
|
||||
:sym-key {:type :string
|
||||
:optional true}}})
|
||||
|
||||
(def v4 {:name :transport
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:ack :string
|
||||
:seen :string
|
||||
:pending-ack :string
|
||||
:pending-send :string
|
||||
:topic :string
|
||||
:fetch-history? {:type :bool
|
||||
:default false}
|
||||
:sym-key-id {:type :string
|
||||
:optional true}
|
||||
;;TODO (yenda) remove once go implements persistence
|
||||
:sym-key {:type :string
|
||||
:optional true}}})
|
||||
|
||||
(def v6 {:name :transport
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:ack :string
|
||||
:seen :string
|
||||
:pending-ack :string
|
||||
:pending-send :string
|
||||
:topic :string
|
||||
:fetch-history? {:type :bool
|
||||
:default false}
|
||||
:resend? {:type :string
|
||||
:optional true}
|
||||
:sym-key-id {:type :string
|
||||
:optional true}
|
||||
;;TODO (yenda) remove once go implements persistence
|
||||
:sym-key {:type :string
|
||||
:optional true}}})
|
|
@ -0,0 +1,12 @@
|
|||
(ns status-im.data-store.realm.schemas.account.user-status)
|
||||
|
||||
(def v1 {:name :user-status
|
||||
:primaryKey :status-id
|
||||
:properties {;; Unfortunately, realm doesn't support composite primary keys,
|
||||
;; so we have to keep separate `:status-id` property, which is just
|
||||
;; `:message-id`-`:whisper-identity` concatenated
|
||||
:status-id :string
|
||||
:message-id :string
|
||||
:chat-id :string
|
||||
:whisper-identity :string
|
||||
:status :string}})
|
|
@ -1,13 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.browser)
|
||||
|
||||
(def schema {:name :browser
|
||||
:primaryKey :browser-id
|
||||
:properties {:browser-id :string
|
||||
:name :string
|
||||
:timestamp :int
|
||||
:dapp? {:type :bool
|
||||
:default false}
|
||||
:url {:type :string
|
||||
:optional true}
|
||||
:contact {:type :string
|
||||
:optional true}}})
|
|
@ -1,32 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.chat
|
||||
(:require [status-im.ui.components.styles :refer [default-chat-color]]))
|
||||
|
||||
(def schema {:name :chat
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:name :string
|
||||
:color {:type :string
|
||||
:default default-chat-color}
|
||||
:group-chat {:type :bool
|
||||
:indexed true}
|
||||
:group-admin {:type :string
|
||||
:optional true}
|
||||
:is-active :bool
|
||||
:timestamp :int
|
||||
:contacts {:type "string[]"}
|
||||
:removed-at {:type :int
|
||||
:optional true}
|
||||
:removed-from-at {:type :int
|
||||
:optional true}
|
||||
:added-to-at {:type :int
|
||||
:optional true}
|
||||
:updated-at {:type :int
|
||||
:optional true}
|
||||
:message-overhead {:type :int
|
||||
:default 0}
|
||||
:contact-info {:type :string
|
||||
:optional true}
|
||||
:debug? {:type :bool
|
||||
:default false}
|
||||
:public? {:type :bool
|
||||
:default false}}})
|
|
@ -1,7 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.chat-contact
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :chat-contact
|
||||
:properties {:identity "string"
|
||||
:is-in-chat {:type "bool"
|
||||
:default true}}})
|
|
@ -1,28 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.contact
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :contact
|
||||
:primaryKey :whisper-identity
|
||||
:properties {:address {:type :string :optional true}
|
||||
:whisper-identity :string
|
||||
:name {:type :string :optional true}
|
||||
:photo-path {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-online {:type :int :default 0}
|
||||
:pending? {:type :bool :default false}
|
||||
:hide-contact? {:type :bool :default false}
|
||||
:status {:type :string :optional true}
|
||||
:fcm-token {:type :string :optional true}
|
||||
:description {:type :string :optional true}
|
||||
:public-key {:type :string
|
||||
:optional true}
|
||||
:dapp? {:type :bool
|
||||
:default false}
|
||||
:dapp-url {:type :string
|
||||
:optional true}
|
||||
:bot-url {:type :string
|
||||
:optional true}
|
||||
:dapp-hash {:type :int
|
||||
:optional true}
|
||||
:debug? {:type :bool
|
||||
:default false}}})
|
|
@ -1,22 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v1.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v1.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v1 account database: " old-realm new-realm))
|
|
@ -1,5 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.group-contact
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :group-contact
|
||||
:properties {:identity "string"}})
|
|
@ -1,7 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.local-storage)
|
||||
|
||||
(def schema {:name :local-storage
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:data {:type :string
|
||||
:default "{}"}}})
|
|
@ -1,28 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.message)
|
||||
|
||||
(def schema {:name :message
|
||||
:primaryKey :message-id
|
||||
:properties {:message-id :string
|
||||
:from :string
|
||||
:to {:type :string
|
||||
:optional true}
|
||||
:content :string ; TODO make it ArrayBuffer
|
||||
:content-type :string
|
||||
:username {:type :string
|
||||
:optional true}
|
||||
:timestamp :int
|
||||
:chat-id {:type :string
|
||||
:indexed true}
|
||||
:outgoing :bool
|
||||
:retry-count {:type :int
|
||||
:default 0}
|
||||
:message-type {:type :string
|
||||
:optional true}
|
||||
:message-status {:type :string
|
||||
:optional true}
|
||||
:user-statuses {:type :list
|
||||
:objectType :user-status}
|
||||
:clock-value {:type :int
|
||||
:default 0}
|
||||
:show? {:type :bool
|
||||
:default true}}})
|
|
@ -1,8 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.request)
|
||||
|
||||
(def schema {:name :request
|
||||
:properties {:message-id :string
|
||||
:chat-id :string
|
||||
:response :string
|
||||
:status {:type :string
|
||||
:default "open"}}})
|
|
@ -1,15 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.transport)
|
||||
|
||||
(def schema {:name :transport
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:ack :string
|
||||
:seen :string
|
||||
:pending-ack :string
|
||||
:pending-send :string
|
||||
:topic :string
|
||||
:sym-key-id {:type :string
|
||||
:optional true}
|
||||
;;TODO (yenda) remove once go implements persistence
|
||||
:sym-key {:type :string
|
||||
:optional true}}})
|
|
@ -1,12 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v1.user-status)
|
||||
|
||||
(def schema {:name :user-status
|
||||
:primaryKey :status-id
|
||||
:properties {;; Unfortunately, realm doesn't support composite primary keys,
|
||||
;; so we have to keep separate `:status-id` property, which is just
|
||||
;; `:message-id`-`:whisper-identity` concatenated
|
||||
:status-id :string
|
||||
:message-id :string
|
||||
:chat-id :string
|
||||
:whisper-identity :string
|
||||
:status :string}})
|
|
@ -1,40 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v10.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v5.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v6.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v7.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v8.browser :as browser]
|
||||
[status-im.data-store.realm.schemas.account.v9.dapp-permissions :as dapp-permissions]
|
||||
[cljs.reader :as reader]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema
|
||||
dapp-permissions/schema])
|
||||
|
||||
(defn message-by-id [realm message-id]
|
||||
(some-> realm
|
||||
(.objects "message")
|
||||
(.filtered (str "message-id = \"" message-id "\""))
|
||||
(aget 0)))
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v10 account database")
|
||||
(some-> old-realm
|
||||
(.objects "request")
|
||||
(.filtered (str "status = \"answered\""))
|
||||
(.map (fn [request _ _]
|
||||
(let [message-id (aget request "message-id")
|
||||
message (message-by-id new-realm message-id)
|
||||
content (reader/read-string (aget message "content"))
|
||||
new-content (assoc-in content [:params :answered?] true)]
|
||||
(aset message "content" (pr-str new-content)))))))
|
|
@ -1,25 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v11.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v5.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v6.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v7.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v11.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v8.browser :as browser]
|
||||
[status-im.data-store.realm.schemas.account.v9.dapp-permissions :as dapp-permissions]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema
|
||||
dapp-permissions/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v11 account database: " old-realm new-realm)
|
||||
(mailserver/migration old-realm new-realm))
|
|
@ -1,17 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v11.mailserver
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :mailserver
|
||||
:primaryKey :id
|
||||
:properties {:id :string
|
||||
:name {:type :string}
|
||||
:address {:type :string}
|
||||
:password {:type :string
|
||||
:optional true}
|
||||
:fleet {:type :string}}})
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating mailservers schema v10")
|
||||
(let [mailservers (.objects new-realm "mailserver")]
|
||||
(dotimes [i (.-length mailservers)]
|
||||
(aset (aget mailservers i) "fleet" "eth.beta"))))
|
|
@ -1,24 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v2.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v1.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v1.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v2 account database: " old-realm new-realm))
|
|
@ -1,11 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v2.mailserver
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :mailserver
|
||||
:primaryKey :id
|
||||
:properties {:id :string
|
||||
:name {:type :string}
|
||||
:address {:type :string}
|
||||
:password {:type :string
|
||||
:optional true}
|
||||
:chain {:type :string}}})
|
|
@ -1,34 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v3.chat
|
||||
(:require [status-im.ui.components.styles :refer [default-chat-color]]))
|
||||
|
||||
(def schema {:name :chat
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:name :string
|
||||
:color {:type :string
|
||||
:default default-chat-color}
|
||||
:group-chat {:type :bool
|
||||
:indexed true}
|
||||
:group-admin {:type :string
|
||||
:optional true}
|
||||
:is-active :bool
|
||||
:timestamp :int
|
||||
:contacts {:type "string[]"}
|
||||
:removed-at {:type :int
|
||||
:optional true}
|
||||
:removed-from-at {:type :int
|
||||
:optional true}
|
||||
:deleted-at-clock-value {:type :int
|
||||
:optional true}
|
||||
:added-to-at {:type :int
|
||||
:optional true}
|
||||
:updated-at {:type :int
|
||||
:optional true}
|
||||
:message-overhead {:type :int
|
||||
:default 0}
|
||||
:contact-info {:type :string
|
||||
:optional true}
|
||||
:debug? {:type :bool
|
||||
:default false}
|
||||
:public? {:type :bool
|
||||
:default false}}})
|
|
@ -1,24 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v3.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v3.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v1.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v3 account database: " old-realm new-realm))
|
|
@ -1,24 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v4.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v3.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v4.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v4 account database: " old-realm new-realm))
|
|
@ -1,17 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v4.transport)
|
||||
|
||||
(def schema {:name :transport
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:ack :string
|
||||
:seen :string
|
||||
:pending-ack :string
|
||||
:pending-send :string
|
||||
:topic :string
|
||||
:fetch-history? {:type :bool
|
||||
:default false}
|
||||
:sym-key-id {:type :string
|
||||
:optional true}
|
||||
;;TODO (yenda) remove once go implements persistence
|
||||
:sym-key {:type :string
|
||||
:optional true}}})
|
|
@ -1,40 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v5.chat
|
||||
(:require
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.ui.components.styles :refer [default-chat-color]]))
|
||||
|
||||
(def schema {:name :chat
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:name :string
|
||||
:color {:type :string
|
||||
:default default-chat-color}
|
||||
:group-chat {:type :bool
|
||||
:indexed true}
|
||||
:group-admin {:type :string
|
||||
:optional true}
|
||||
:is-active :bool
|
||||
:timestamp :int
|
||||
:contacts {:type "string[]"}
|
||||
:removed-at {:type :int
|
||||
:optional true}
|
||||
:removed-from-at {:type :int
|
||||
:optional true}
|
||||
:deleted-at-clock-value {:type :int
|
||||
:optional true}
|
||||
:added-to-at {:type :int
|
||||
:optional true}
|
||||
:updated-at {:type :int
|
||||
:optional true}
|
||||
:message-overhead {:type :int
|
||||
:default 0}
|
||||
:debug? {:type :bool
|
||||
:default false}
|
||||
:public? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating chats schema v5")
|
||||
(let [chats (.objects new-realm "chat")]
|
||||
(dotimes [i (.-length chats)]
|
||||
(js-delete (aget chats i) "contact-info"))))
|
|
@ -1,25 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v5.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v5.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v4.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v5 account database: " old-realm new-realm)
|
||||
(chat/migration old-realm new-realm))
|
|
@ -1,24 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v6.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v5.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v6.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v6 account database: " old-realm new-realm))
|
|
@ -1,19 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v6.transport)
|
||||
|
||||
(def schema {:name :transport
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:ack :string
|
||||
:seen :string
|
||||
:pending-ack :string
|
||||
:pending-send :string
|
||||
:topic :string
|
||||
:fetch-history? {:type :bool
|
||||
:default false}
|
||||
:resend? {:type :string
|
||||
:optional true}
|
||||
:sym-key-id {:type :string
|
||||
:optional true}
|
||||
;;TODO (yenda) remove once go implements persistence
|
||||
:sym-key {:type :string
|
||||
:optional true}}})
|
|
@ -1,25 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v7.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v5.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v6.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v7.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v7 account database: " old-realm new-realm)
|
||||
(message/migration old-realm new-realm))
|
|
@ -1,33 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v7.message
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :message
|
||||
:primaryKey :message-id
|
||||
:properties {:message-id :string
|
||||
:from :string
|
||||
:to {:type :string
|
||||
:optional true}
|
||||
:content :string ; TODO make it ArrayBuffer
|
||||
:content-type :string
|
||||
:username {:type :string
|
||||
:optional true}
|
||||
:timestamp :int
|
||||
:chat-id {:type :string
|
||||
:indexed true}
|
||||
:outgoing :bool
|
||||
:retry-count {:type :int
|
||||
:default 0}
|
||||
:message-type {:type :string
|
||||
:optional true}
|
||||
:message-status {:type :string
|
||||
:optional true}
|
||||
:clock-value {:type :int
|
||||
:default 0}
|
||||
:show? {:type :bool
|
||||
:default true}}})
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating messages schema v7")
|
||||
(let [messages (.objects new-realm "message")]
|
||||
(dotimes [i (.-length messages)]
|
||||
(js-delete (aget messages i) "user-statuses"))))
|
|
@ -1,25 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v8.browser
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :browser
|
||||
:primaryKey :browser-id
|
||||
:properties {:browser-id :string
|
||||
:name :string
|
||||
:timestamp :int
|
||||
:dapp? {:type :bool
|
||||
:default false}
|
||||
:history-index {:type :int
|
||||
:optional true}
|
||||
:history {:type "string[]"
|
||||
:optional true}}})
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating browser schema v8")
|
||||
(let [browsers (.objects new-realm "browser")
|
||||
old-browsers (.objects old-realm "browser")]
|
||||
(dotimes [i (.-length browsers)]
|
||||
(let [browser (aget browsers i)
|
||||
old-browser (aget old-browsers i)
|
||||
url (aget old-browser "url")]
|
||||
(aset browser "history-index" 0)
|
||||
(aset browser "history" (clj->js [url]))))))
|
|
@ -1,25 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v8.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v5.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v6.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v7.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v8.browser :as browser]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v8 account database: " old-realm new-realm)
|
||||
(browser/migration old-realm new-realm))
|
|
@ -1,26 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v9.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v5.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v6.transport :as transport]
|
||||
[status-im.data-store.realm.schemas.account.v1.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v7.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||
[status-im.data-store.realm.schemas.account.v2.mailserver :as mailserver]
|
||||
[status-im.data-store.realm.schemas.account.v8.browser :as browser]
|
||||
[status-im.data-store.realm.schemas.account.v9.dapp-permissions :as dapp-permissions]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
transport/schema
|
||||
contact/schema
|
||||
message/schema
|
||||
request/schema
|
||||
mailserver/schema
|
||||
user-status/schema
|
||||
local-storage/schema
|
||||
browser/schema
|
||||
dapp-permissions/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v9 account database: " old-realm new-realm))
|
|
@ -1,7 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v9.dapp-permissions)
|
||||
|
||||
(def schema {:name :dapp-permissions
|
||||
:primaryKey :dapp
|
||||
:properties {:dapp :string
|
||||
:permissions {:type "string[]"
|
||||
:optional true}}})
|
|
@ -0,0 +1,200 @@
|
|||
(ns status-im.data-store.realm.schemas.base.account)
|
||||
|
||||
(def v1 {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool :default false}}})
|
||||
|
||||
(def v2 {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(def v3 {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(def v4 {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:bootnodes {:type :list
|
||||
:objectType :bootnode}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(def v6 {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:bootnodes {:type :list
|
||||
:objectType :bootnode}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}
|
||||
:mainnet-warning-shown? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(def v7 {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:bootnodes {:type :list
|
||||
:objectType :bootnode}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}
|
||||
:mainnet-warning-shown? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
;;NOTE(yenda): this was a mistake made because of the previous
|
||||
;;way realm migrations were specified
|
||||
(def v8 v4)
|
||||
|
||||
(def v10 {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:bootnodes {:type :list
|
||||
:objectType :bootnode}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}
|
||||
:mainnet-warning-shown? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(def v11 (assoc-in v10
|
||||
[:properties :installation-id]
|
||||
{:type :string}))
|
|
@ -0,0 +1,8 @@
|
|||
(ns status-im.data-store.realm.schemas.base.bootnode)
|
||||
|
||||
(def v4 {:name :bootnode
|
||||
:primaryKey :id
|
||||
:properties {:id :string
|
||||
:name {:type :string}
|
||||
:chain {:type :string}
|
||||
:address {:type :string}}})
|
|
@ -1,47 +1,77 @@
|
|||
(ns status-im.data-store.realm.schemas.base.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.core :as v1]
|
||||
[status-im.data-store.realm.schemas.base.v2.core :as v2]
|
||||
[status-im.data-store.realm.schemas.base.v3.core :as v3]
|
||||
[status-im.data-store.realm.schemas.base.v4.core :as v4]
|
||||
[status-im.data-store.realm.schemas.base.v5.core :as v5]
|
||||
[status-im.data-store.realm.schemas.base.v6.core :as v6]
|
||||
[status-im.data-store.realm.schemas.base.v7.core :as v7]
|
||||
[status-im.data-store.realm.schemas.base.v8.core :as v8]
|
||||
[status-im.data-store.realm.schemas.base.v9.core :as v9]
|
||||
[status-im.data-store.realm.schemas.base.v10.core :as v10]
|
||||
[status-im.data-store.realm.schemas.base.v11.core :as v11]))
|
||||
(:require [status-im.data-store.realm.schemas.base.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.account :as account]
|
||||
[status-im.data-store.realm.schemas.base.bootnode :as bootnode]
|
||||
[status-im.data-store.realm.schemas.base.migrations :as migrations]))
|
||||
|
||||
(def v1 [network/v1
|
||||
account/v1])
|
||||
|
||||
(def v2 [network/v1
|
||||
account/v2])
|
||||
|
||||
(def v3 [network/v1
|
||||
account/v3])
|
||||
|
||||
(def v4 [network/v1
|
||||
bootnode/v4
|
||||
account/v4])
|
||||
|
||||
(def v5 v4)
|
||||
|
||||
(def v6 [network/v1
|
||||
bootnode/v4
|
||||
account/v6])
|
||||
|
||||
(def v7 [network/v1
|
||||
bootnode/v4
|
||||
account/v7])
|
||||
|
||||
(def v8 [network/v1
|
||||
bootnode/v4
|
||||
account/v8])
|
||||
|
||||
(def v9 v8)
|
||||
|
||||
(def v10 [network/v1
|
||||
bootnode/v4
|
||||
account/v10])
|
||||
|
||||
(def v11 [network/v1
|
||||
bootnode/v4
|
||||
account/v11])
|
||||
|
||||
;; put schemas ordered by version
|
||||
(def schemas [{:schema v1/schema
|
||||
(def schemas [{:schema v1
|
||||
:schemaVersion 1
|
||||
:migration v1/migration}
|
||||
{:schema v2/schema
|
||||
:migration migrations/v1}
|
||||
{:schema v2
|
||||
:schemaVersion 2
|
||||
:migration v2/migration}
|
||||
{:schema v3/schema
|
||||
:migration migrations/v2}
|
||||
{:schema v3
|
||||
:schemaVersion 3
|
||||
:migration v3/migration}
|
||||
{:schema v4/schema
|
||||
:migration migrations/v3}
|
||||
{:schema v4
|
||||
:schemaVersion 4
|
||||
:migration v4/migration}
|
||||
{:schema v5/schema
|
||||
:migration migrations/v4}
|
||||
{:schema v5
|
||||
:schemaVersion 5
|
||||
:migration v5/migration}
|
||||
{:schema v6/schema
|
||||
:migration migrations/v5}
|
||||
{:schema v6
|
||||
:schemaVersion 6
|
||||
:migration v6/migration}
|
||||
{:schema v7/schema
|
||||
:migration migrations/v6}
|
||||
{:schema v7
|
||||
:schemaVersion 7
|
||||
:migration v7/migration}
|
||||
{:schema v8/schema
|
||||
:migration migrations/v7}
|
||||
{:schema v8
|
||||
:schemaVersion 8
|
||||
:migration v8/migration}
|
||||
{:schema v9/schema
|
||||
:migration migrations/v8}
|
||||
{:schema v9
|
||||
:schemaVersion 9
|
||||
:migration v9/migration}
|
||||
{:schema v10/schema
|
||||
:migration migrations/v9}
|
||||
{:schema v10
|
||||
:schemaVersion 10
|
||||
:migration v10/migration}
|
||||
{:schema v11/schema
|
||||
:migration migrations/v10}
|
||||
{:schema v11
|
||||
:schemaVersion 11
|
||||
:migration v11/migration}])
|
||||
:migration migrations/v11}])
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
(ns status-im.data-store.realm.schemas.base.migrations
|
||||
(:require [taoensso.timbre :as log]
|
||||
[cognitect.transit :as transit]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as string]
|
||||
[status-im.utils.random :as random]))
|
||||
|
||||
(def reader (transit/reader :json))
|
||||
(def writer (transit/writer :json))
|
||||
|
||||
(defn serialize [o] (transit/write writer o))
|
||||
(defn deserialize [o] (try (transit/read reader o) (catch :default e nil)))
|
||||
|
||||
(defn v1 [old-realm new-realm]
|
||||
(log/debug "migrating base database v1: " old-realm new-realm))
|
||||
|
||||
(defn v2 [old-realm new-realm]
|
||||
(log/debug "migrating base database v2: " old-realm new-realm))
|
||||
|
||||
(defn v3 [old-realm new-realm]
|
||||
(log/debug "migrating base database v3: " old-realm new-realm))
|
||||
|
||||
(defn v4 [old-realm new-realm]
|
||||
(log/debug "migrating base database v4: " old-realm new-realm))
|
||||
|
||||
(def removed-tokens-v5
|
||||
#{:ATMChain :Centra :ROL})
|
||||
|
||||
(def removed-fiat-currencies
|
||||
#{:bmd :bzd :gmd :gyd :kyd :lak :lrd :ltl :mkd :mnt :nio :sos :srd :yer})
|
||||
|
||||
(defn v5 [old-realm new-realm]
|
||||
(log/debug "migrating accounts schema v4")
|
||||
(let [accounts (.objects new-realm "account")]
|
||||
(dotimes [i (.-length accounts)]
|
||||
(let [account (aget accounts i)
|
||||
old-settings (deserialize (aget account "settings"))
|
||||
new-settings (-> old-settings
|
||||
(update-in [:wallet :visible-tokens :mainnet]
|
||||
#(set/difference % removed-tokens-v5))
|
||||
(update-in [:wallet :currency]
|
||||
#(if (removed-fiat-currencies %) :usd %)))
|
||||
updated (serialize new-settings)]
|
||||
(aset account "settings" updated)))))
|
||||
|
||||
(defn v6 [old-realm new-realm]
|
||||
(log/debug "migrating base database v6: " old-realm new-realm))
|
||||
|
||||
(defn v7 [old-realm new-realm]
|
||||
(log/debug "migrating base database v7: " old-realm new-realm))
|
||||
|
||||
(def removed-tokens-v8
|
||||
#{:ATT})
|
||||
|
||||
(defn v8 [old-realm new-realm]
|
||||
(log/debug "migrating accounts schema v8")
|
||||
(let [accounts (.objects new-realm "account")]
|
||||
(dotimes [i (.-length accounts)]
|
||||
(let [account (aget accounts i)
|
||||
old-settings (deserialize (aget account "settings"))
|
||||
new-settings (-> old-settings
|
||||
(update-in [:wallet :visible-tokens :testnet]
|
||||
#(set/difference % removed-tokens-v8)))
|
||||
updated (serialize new-settings)]
|
||||
(aset account "settings" updated)))))
|
||||
|
||||
(defn v9 [old-realm new-realm]
|
||||
(log/debug "migrating accounts schema v9")
|
||||
(let [accounts (.objects new-realm "account")]
|
||||
(dotimes [i (.-length accounts)]
|
||||
(let [account (aget accounts i)
|
||||
old-settings (deserialize (aget account "settings"))
|
||||
new-settings (-> old-settings
|
||||
(dissoc :wnode))
|
||||
updated (serialize new-settings)]
|
||||
(aset account "settings" updated)))))
|
||||
|
||||
(defn v10 [old-realm new-realm]
|
||||
(log/debug "migrating base database v10: " old-realm new-realm))
|
||||
|
||||
(defn v11 [old-realm new-realm]
|
||||
(log/debug "migrating accounts schema v11")
|
||||
(let [accounts (.objects new-realm "account")]
|
||||
(dotimes [i (.-length accounts)]
|
||||
(let [account (aget accounts i)
|
||||
old-installation-id (aget account "installation-id")
|
||||
installation-id (random/guid)]
|
||||
(when (string/blank? old-installation-id)
|
||||
(aset account "installation-id" installation-id))))))
|
|
@ -0,0 +1,11 @@
|
|||
(ns status-im.data-store.realm.schemas.base.network)
|
||||
|
||||
(def v1 {:name :network
|
||||
:primaryKey :id
|
||||
:properties {:id :string
|
||||
:name {:type :string
|
||||
:optional true}
|
||||
:config {:type :string
|
||||
:optional true}
|
||||
:rpc-url {:type :string
|
||||
:optional true}}})
|
|
@ -1,25 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v1.account)
|
||||
|
||||
(def schema {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool :default false}}})
|
|
@ -1,10 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v1.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v1.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v1: " old-realm new-realm))
|
|
@ -1,12 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v1.network
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :network
|
||||
:primaryKey :id
|
||||
:properties {:id :string
|
||||
:name {:type :string
|
||||
:optional true}
|
||||
:config {:type :string
|
||||
:optional true}
|
||||
:rpc-url {:type :string
|
||||
:optional true}}})
|
|
@ -1,30 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v10.account)
|
||||
|
||||
(def schema {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:bootnodes {:type :list
|
||||
:objectType :bootnode}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}
|
||||
:mainnet-warning-shown? {:type :bool
|
||||
:default false}}})
|
|
@ -1,12 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v10.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||
[status-im.data-store.realm.schemas.base.v10.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
bootnode/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v10: " old-realm new-realm))
|
|
@ -1,22 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v11.account
|
||||
(:require [taoensso.timbre :as log]
|
||||
[clojure.string :as string]
|
||||
[cognitect.transit :as transit]
|
||||
[clojure.set :as set]
|
||||
[status-im.utils.random :as random]
|
||||
[status-im.data-store.realm.schemas.base.v10.account :as v10]))
|
||||
|
||||
(def schema
|
||||
(assoc-in v10/schema
|
||||
[:properties :installation-id]
|
||||
{:type :string}))
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating accounts schema v11")
|
||||
(let [accounts (.objects new-realm "account")]
|
||||
(dotimes [i (.-length accounts)]
|
||||
(let [account (aget accounts i)
|
||||
old-installation-id (aget account "installation-id")
|
||||
installation-id (random/guid)]
|
||||
(when (string/blank? old-installation-id)
|
||||
(aset account "installation-id" installation-id))))))
|
|
@ -1,13 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v11.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||
[status-im.data-store.realm.schemas.base.v11.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
bootnode/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v11: " old-realm new-realm)
|
||||
(account/migration old-realm new-realm))
|
|
@ -1,26 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v2.account)
|
||||
|
||||
(def schema {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}}})
|
|
@ -1,10 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v2.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v2.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v2: " old-realm new-realm))
|
|
@ -1,27 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v3.account)
|
||||
|
||||
(def schema {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}}})
|
|
@ -1,10 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v3.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v3.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v3: " old-realm new-realm))
|
|
@ -1,29 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v4.account)
|
||||
|
||||
(def schema {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:bootnodes {:type :list
|
||||
:objectType :bootnode}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}}})
|
|
@ -1,8 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v4.bootnode)
|
||||
|
||||
(def schema {:name :bootnode
|
||||
:primaryKey :id
|
||||
:properties {:id :string
|
||||
:name {:type :string}
|
||||
:chain {:type :string}
|
||||
:address {:type :string}}})
|
|
@ -1,12 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v4.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v4.account :as account]
|
||||
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
bootnode/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v4: " old-realm new-realm))
|
|
@ -1,33 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v5.account
|
||||
(:require [taoensso.timbre :as log]
|
||||
[cognitect.transit :as transit]
|
||||
[clojure.set :as set]
|
||||
[status-im.data-store.realm.schemas.base.v4.account :as v4]))
|
||||
|
||||
(def schema v4/schema)
|
||||
|
||||
(def removed-tokens
|
||||
#{:ATMChain :Centra :ROL})
|
||||
|
||||
(def removed-fiat-currencies
|
||||
#{:bmd :bzd :gmd :gyd :kyd :lak :lrd :ltl :mkd :mnt :nio :sos :srd :yer})
|
||||
|
||||
(def reader (transit/reader :json))
|
||||
(def writer (transit/writer :json))
|
||||
|
||||
(defn serialize [o] (transit/write writer o))
|
||||
(defn deserialize [o] (try (transit/read reader o) (catch :default e nil)))
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating accounts schema v4")
|
||||
(let [accounts (.objects new-realm "account")]
|
||||
(dotimes [i (.-length accounts)]
|
||||
(let [account (aget accounts i)
|
||||
old-settings (deserialize (aget account "settings"))
|
||||
new-settings (-> old-settings
|
||||
(update-in [:wallet :visible-tokens :mainnet]
|
||||
#(set/difference % removed-tokens))
|
||||
(update-in [:wallet :currency]
|
||||
#(if (removed-fiat-currencies %) :usd %)))
|
||||
updated (serialize new-settings)]
|
||||
(aset account "settings" updated)))))
|
|
@ -1,13 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v5.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||
[status-im.data-store.realm.schemas.base.v5.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
bootnode/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v5: " old-realm new-realm)
|
||||
(account/migration old-realm new-realm))
|
|
@ -1,31 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v6.account)
|
||||
|
||||
(def schema {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:bootnodes {:type :list
|
||||
:objectType :bootnode}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:sharing-usage-data? {:type :bool :default false}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}
|
||||
:mainnet-warning-shown? {:type :bool
|
||||
:default false}}})
|
|
@ -1,12 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v6.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||
[status-im.data-store.realm.schemas.base.v6.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
bootnode/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v6: " old-realm new-realm))
|
|
@ -1,30 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v7.account)
|
||||
|
||||
(def schema {:name :account
|
||||
:primaryKey :address
|
||||
:properties {:address :string
|
||||
:public-key :string
|
||||
:name {:type :string :optional true}
|
||||
:email {:type :string :optional true}
|
||||
:status {:type :string :optional true}
|
||||
:debug? {:type :bool :default false}
|
||||
:photo-path :string
|
||||
:signing-phrase {:type :string}
|
||||
:mnemonic {:type :string :optional true}
|
||||
:last-updated {:type :int :default 0}
|
||||
:last-sign-in {:type :int :default 0}
|
||||
:signed-up? {:type :bool
|
||||
:default false}
|
||||
:network :string
|
||||
:networks {:type :list
|
||||
:objectType :network}
|
||||
:bootnodes {:type :list
|
||||
:objectType :bootnode}
|
||||
:last-request {:type :int :optional true}
|
||||
:settings {:type :string}
|
||||
:dev-mode? {:type :bool :default false}
|
||||
:seed-backed-up? {:type :bool :default false}
|
||||
:wallet-set-up-passed? {:type :bool
|
||||
:default false}
|
||||
:mainnet-warning-shown? {:type :bool
|
||||
:default false}}})
|
|
@ -1,12 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v7.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||
[status-im.data-store.realm.schemas.base.v7.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
bootnode/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v7: " old-realm new-realm))
|
|
@ -1,28 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v8.account
|
||||
(:require [taoensso.timbre :as log]
|
||||
[cognitect.transit :as transit]
|
||||
[clojure.set :as set]
|
||||
[status-im.data-store.realm.schemas.base.v4.account :as v7]))
|
||||
|
||||
(def schema v7/schema)
|
||||
|
||||
(def removed-tokens
|
||||
#{:ATT})
|
||||
|
||||
(def reader (transit/reader :json))
|
||||
(def writer (transit/writer :json))
|
||||
|
||||
(defn serialize [o] (transit/write writer o))
|
||||
(defn deserialize [o] (try (transit/read reader o) (catch :default e nil)))
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating accounts schema v8")
|
||||
(let [accounts (.objects new-realm "account")]
|
||||
(dotimes [i (.-length accounts)]
|
||||
(let [account (aget accounts i)
|
||||
old-settings (deserialize (aget account "settings"))
|
||||
new-settings (-> old-settings
|
||||
(update-in [:wallet :visible-tokens :testnet]
|
||||
#(set/difference % removed-tokens)))
|
||||
updated (serialize new-settings)]
|
||||
(aset account "settings" updated)))))
|
|
@ -1,13 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v8.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||
[status-im.data-store.realm.schemas.base.v8.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
bootnode/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v8: " old-realm new-realm)
|
||||
(account/migration old-realm new-realm))
|
|
@ -1,24 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v9.account
|
||||
(:require [taoensso.timbre :as log]
|
||||
[cognitect.transit :as transit]
|
||||
[clojure.set :as set]
|
||||
[status-im.data-store.realm.schemas.base.v8.account :as v8]))
|
||||
|
||||
(def schema v8/schema)
|
||||
|
||||
(def reader (transit/reader :json))
|
||||
(def writer (transit/writer :json))
|
||||
|
||||
(defn serialize [o] (transit/write writer o))
|
||||
(defn deserialize [o] (try (transit/read reader o) (catch :default e nil)))
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating accounts schema v9")
|
||||
(let [accounts (.objects new-realm "account")]
|
||||
(dotimes [i (.-length accounts)]
|
||||
(let [account (aget accounts i)
|
||||
old-settings (deserialize (aget account "settings"))
|
||||
new-settings (-> old-settings
|
||||
(dissoc :wnode))
|
||||
updated (serialize new-settings)]
|
||||
(aset account "settings" updated)))))
|
|
@ -1,13 +0,0 @@
|
|||
(ns status-im.data-store.realm.schemas.base.v9.core
|
||||
(:require [status-im.data-store.realm.schemas.base.v1.network :as network]
|
||||
[status-im.data-store.realm.schemas.base.v4.bootnode :as bootnode]
|
||||
[status-im.data-store.realm.schemas.base.v9.account :as account]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [network/schema
|
||||
bootnode/schema
|
||||
account/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating base database v9: " old-realm new-realm)
|
||||
(account/migration old-realm new-realm))
|
Loading…
Reference in New Issue