Remove migrations as they are not needed anymore because of breaking change

Signed-off-by: Eric Dvorsak <eric@dvorsak.fr>
This commit is contained in:
Eric Dvorsak 2018-04-06 19:05:15 +02:00
parent 52746f4363
commit d9eca279d0
No known key found for this signature in database
GPG Key ID: 932AC1CE5F05DE0C
98 changed files with 120 additions and 2870 deletions

View File

@ -1,6 +1,6 @@
(ns status-im.data-store.core
(:require status-im.data-store.chats
status-im.data-store.messages
status-im.data-store.messages
status-im.data-store.contacts
status-im.data-store.transport
status-im.data-store.browser

View File

@ -1,33 +0,0 @@
(ns status-im.data-store.discover
(:require [re-frame.core :as re-frame]
[status-im.data-store.realm.discover :as data-store]
[status-im.utils.handlers :as handlers]))
;; stores a collection of discover messages
;; removes the tags from the discovers because there is no
;; need to store them and realm doesn't support lists
;; of string
;; also deletes the oldest queries if the number of discovers stored is
;; above maximum-number-of-discoveries
(re-frame/reg-fx
:data-store/save-all-discoveries
(fn [[discovers maximum-number-of-discoveries]]
(data-store/save-all (mapv #(dissoc % :tags) discovers))
(data-store/delete :created-at :asc maximum-number-of-discoveries)))
(defn get-all
;; extracts the hashtags from the status and put them into a set
;; for each discover
;; returns a map of discovers that can be used as is in the app-db
[]
(reduce (fn [acc {:keys [message-id status] :as discover}]
(let [tags (handlers/get-hashtags status)
discover (assoc discover :tags tags)]
(assoc acc message-id discover)))
{}
(data-store/get-all-as-list :asc)))
(re-frame/reg-cofx
:data-store/discoveries
(fn [cofx _]
(assoc cofx :data-store/discoveries (get-all))))

View File

@ -1,39 +0,0 @@
(ns status-im.data-store.realm.discover
(:require [status-im.data-store.realm.core :as realm]
[taoensso.timbre :as log])
(:refer-clojure :exclude [exists?]))
(defn get-all
[ordering]
(-> @realm/account-realm
(realm/get-all :discover)
(realm/sorted :created-at ordering)))
(defn get-all-as-list
[ordering]
(realm/js-object->clj (get-all ordering)))
(defn save
[discover]
(realm/write @realm/account-realm
#(realm/create @realm/account-realm :discover discover true)))
(defn save-all
[discoveries]
(realm/write @realm/account-realm
(fn []
(doseq [discover discoveries]
(realm/create @realm/account-realm :discover discover true)))))
(defn delete
[by ordering max-count]
(let [discoveries (realm/get-all @realm/account-realm :discover)
count (realm/get-count discoveries)]
(if (> count max-count)
(let [to-delete (-> discoveries
(realm/sorted by ordering)
(realm/page 0 (- max-count count)))]
(realm/write @realm/account-realm
(fn []
(log/debug (str "Deleting " (realm/get-count to-delete) " discoveries"))
(realm/delete @realm/account-realm to-delete)))))))

View File

@ -1,98 +1,9 @@
(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]
[status-im.data-store.realm.schemas.account.v12.core :as v12]
[status-im.data-store.realm.schemas.account.v13.core :as v13]
[status-im.data-store.realm.schemas.account.v14.core :as v14]
[status-im.data-store.realm.schemas.account.v15.core :as v15]
[status-im.data-store.realm.schemas.account.v16.core :as v16]
[status-im.data-store.realm.schemas.account.v17.core :as v17]
[status-im.data-store.realm.schemas.account.v18.core :as v18]
[status-im.data-store.realm.schemas.account.v19.core :as v19]
[status-im.data-store.realm.schemas.account.v20.core :as v20]
[status-im.data-store.realm.schemas.account.v21.core :as v21]
[status-im.data-store.realm.schemas.account.v22.core :as v22]
[status-im.data-store.realm.schemas.account.v23.core :as v23]))
(:require [status-im.data-store.realm.schemas.account.v1.core :as v1]))
;; TODO(oskarth): Add failing test if directory vXX exists but isn't in schemas.
;; put schemas ordered by version
(def schemas [{:schema v1/schema
:schemaVersion 1
:migration v1/migration}
{:schema v2/schema
:schemaVersion 2
:migration v2/migration}
{:schema v3/schema
:schemaVersion 3
:migration v3/migration}
{:schema v4/schema
:schemaVersion 4
:migration v4/migration}
{:schema v5/schema
:schemaVersion 5
:migration v5/migration}
{:schema v6/schema
:schemaVersion 6
:migration v6/migration}
{:schema v7/schema
:schemaVersion 7
:migration v7/migration}
{:schema v8/schema
:schemaVersion 8
:migration v8/migration}
{:schema v9/schema
:schemaVersion 9
:migration v9/migration}
{:schema v10/schema
:schemaVersion 10
:migration v10/migration}
{:schema v11/schema
:schemaVersion 11
:migration v11/migration}
{:schema v12/schema
:schemaVersion 12
:migration v12/migration}
{:schema v13/schema
:schemaVersion 13
:migration v13/migration}
{:schema v14/schema
:schemaVersion 14
:migration v14/migration}
{:schema v15/schema
:schemaVersion 15
:migration v15/migration}
{:schema v16/schema
:schemaVersion 16
:migration v16/migration}
{:schema v17/schema
:schemaVersion 17
:migration v17/migration}
{:schema v18/schema
:schemaVersion 18
:migration v18/migration}
{:schema v19/schema
:schemaVersion 19
:migration v19/migration}
{:schema v20/schema
:schemaVersion 20
:migration v20/migration}
{:schema v21/schema
:schemaVersion 21
:migration v21/migration}
{:schema v22/schema
:schemaVersion 22
:migration v22/migration}
{:schema v23/schema
:schemaVersion 23
:migration v23/migration}])
:migration v1/migration}])

View File

@ -1,4 +1,4 @@
(ns status-im.data-store.realm.schemas.account.v21.browser)
(ns status-im.data-store.realm.schemas.account.v1.browser)
(def schema {:name :browser
:primaryKey :browser-id

View File

@ -1,6 +1,5 @@
(ns status-im.data-store.realm.schemas.account.v1.chat
(:require [taoensso.timbre :as log]
[status-im.ui.components.styles :refer [default-chat-color]]))
(:require [status-im.ui.components.styles :refer [default-chat-color]]))
(def schema {:name :chat
:primaryKey :chat-id
@ -16,6 +15,8 @@
:timestamp :int
:contacts {:type :list
:objectType :chat-contact}
:unremovable? {:type :bool
:default false}
:removed-at {:type :int
:optional true}
:removed-from-at {:type :int
@ -24,17 +25,11 @@
:optional true}
:updated-at {:type :int
:optional true}
:last-message-id :string
:message-overhead {:type :int
:default 0}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:pending-contact? {:type :bool
:default false}
:contact-info {:type :string
:optional true}}})
(defn migration [_ _]
(log/debug "migrating chat schema"))
:optional true}
:debug? {:type :bool
:default false}
:public? {:type :bool
:default false}}})

View File

@ -5,6 +5,3 @@
:properties {:identity "string"
:is-in-chat {:type "bool"
:default true}}})
(defn migration [_ _]
(log/debug "migrating chat-contact schema"))

View File

@ -1,10 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v1.command
(:require [taoensso.timbre :as log]))
(def schema {:name :command
:primaryKey :chat-id
:properties {:chat-id "string"
:file "string"}})
(defn migration [_ _]
(log/debug "migrating command schema"))

View File

@ -3,25 +3,26 @@
(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}
:status {:type "string" :optional true}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:keys-last-updated {:type "int" :default 0}
:dapp? {:type :bool
:default false}
:dapp-url {:type :string
:optional true}
:dapp-hash {:type :int
:optional true}}})
(defn migration [_ _]
(log/debug "migrating contact schema"))
: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}}})

View File

@ -1,4 +1,4 @@
(ns status-im.data-store.realm.schemas.account.v5.contact-group
(ns status-im.data-store.realm.schemas.account.v1.contact-group
(:require [taoensso.timbre :as log]))
(def schema {:name :contact-group
@ -10,6 +10,3 @@
:pending? {:type :bool :default false}
:contacts {:type :list
:objectType :group-contact}}})
(defn migration [old-realm new-realm]
(log/debug "migrating group schema v5"))

View File

@ -1,42 +1,31 @@
(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.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v1.command :as command]
[status-im.data-store.realm.schemas.account.v1.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.v1.message :as message]
[status-im.data-store.realm.schemas.account.v1.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]
[taoensso.timbre :as log]))
[status-im.data-store.realm.schemas.account.v1.contact-group :as contact-group]
[status-im.data-store.realm.schemas.account.v1.group-contact :as group-contact]
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
[goog.object :as object]
[taoensso.timbre :as log]
[cljs.reader :as reader]
[clojure.string :as string]))
(def schema [chat/schema
chat-contact/schema
command/schema
transport/schema
contact/schema
discover/schema
kv-store/schema
message/schema
pending-message/schema
processed-message/schema
request/schema
tag/schema
user-status/schema])
user-status/schema
contact-group/schema
group-contact/schema
local-storage/schema
browser/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v1 account database: " old-realm new-realm)
(chat/migration old-realm new-realm)
(chat-contact/migration old-realm new-realm)
(command/migration old-realm new-realm)
(contact/migration old-realm new-realm)
(discover/migration old-realm new-realm)
(kv-store/migration old-realm new-realm)
(message/migration old-realm new-realm)
(pending-message/migration old-realm new-realm)
(processed-message/migration old-realm new-realm)
(request/migration old-realm new-realm)
(tag/migration old-realm new-realm)
(user-status/migration old-realm new-realm))
(log/debug "migrating v1 account database: " old-realm new-realm))

View File

@ -1,16 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v1.discover
(:require [taoensso.timbre :as log]))
(def schema {:name :discover
:primaryKey :message-id
:properties {:message-id "string"
:name {:type "string" :optional true}
:status "string"
:whisper-id "string"
:photo-path {:type "string" :optional true}
:tags {:type "list"
:objectType "tag"}
:created-at {:type "int" :default 0}}})
(defn migration [_ _]
(log/debug "migrating discover schema"))

View File

@ -0,0 +1,5 @@
(ns status-im.data-store.realm.schemas.account.v1.group-contact
(:require [taoensso.timbre :as log]))
(def schema {:name :group-contact
:properties {:identity "string"}})

View File

@ -1,10 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v1.kv-store
(:require [taoensso.timbre :as log]))
(def schema {:name :kv-store
:primaryKey :key
:properties {:key "string"
:value "string"}})
(defn migration [_ _]
(log/debug "migrating kv-store schema"))

View File

@ -1,4 +1,4 @@
(ns status-im.data-store.realm.schemas.account.v8.local-storage)
(ns status-im.data-store.realm.schemas.account.v1.local-storage)
(def schema {:name :local-storage
:primaryKey :chat-id

View File

@ -1,36 +1,30 @@
(ns status-im.data-store.realm.schemas.account.v1.message
(:require [taoensso.timbre :as log]))
(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}
:group-id {:type "string"
:optional true}
:content "string" ;; TODO make it ArrayBuffer
:content-type "string"
:timestamp "int"
:chat-id {:type "string"
:indexed true}
:outgoing "bool"
:retry-count {:type :int
:default 0}
:same-author "bool"
:same-direction "bool"
:preview {:type :string
:optional true}
: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}}})
(defn migration [_ _]
(log/debug "migrating message schema"))
: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}
:from-clock-value {:type :int
:default 0}
:to-clock-value {:type :int
:default 0}
:show? {:type :bool
:default true}}})

View File

@ -1,22 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v1.pending-message
(:require [taoensso.timbre :as log]))
(def schema {:name :pending-message
:primaryKey :id
:properties {:id :string
:message-id :string
:chat-id {:type :string
:optional true}
:ack? :bool
:requires-ack? :bool
:from :string
:to {:type :string
:optional true}
:payload :string
:type :string
:topics :string
:attempts :int
:was-sent? :bool}})
(defn migration [_ _]
(log/debug "migrating pending-message schema"))

View File

@ -1,13 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v1.processed-message
(:require [taoensso.timbre :as log]))
(def schema {:name :processed-message
:primaryKey :id
:properties {:id :string
:message-id :string
:type {:type "string"
:optional true}
:ttl :int}})
(defn migration [_ _]
(log/debug "migrating processed-message schema"))

View File

@ -1,13 +1,8 @@
(ns status-im.data-store.realm.schemas.account.v1.request
(:require [taoensso.timbre :as log]))
(ns status-im.data-store.realm.schemas.account.v1.request)
(def schema {:name :request
:properties {:message-id :string
:chat-id :string
:type :string
:response :string
:status {:type :string
:default "open"}
:added :date}})
(defn migration [_ _]
(log/debug "migrating request schema"))
:default "open"}}})

View File

@ -1,10 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v1.tag
(:require [taoensso.timbre :as log]))
(def schema {:name :tag
:primaryKey :name
:properties {:name "string"
:count {:type "int" :optional true :default 0}}})
(defn migration [_ _]
(log/debug "migrating tag schema"))

View File

@ -1,4 +1,4 @@
(ns status-im.data-store.realm.schemas.account.v22.transport)
(ns status-im.data-store.realm.schemas.account.v1.transport)
(def schema {:name :transport
:primaryKey :chat-id

View File

@ -1,12 +1,12 @@
(ns status-im.data-store.realm.schemas.account.v1.user-status
(:require [taoensso.timbre :as log]))
(ns status-im.data-store.realm.schemas.account.v1.user-status)
(def schema {:name :user-status
:primaryKey :id
:properties {:id "string"
:whisper-identity {:type "string"
:default ""}
:status "string"}})
(defn migration [_ _]
(log/debug "migrating user-status schema"))
: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}})

View File

@ -1,39 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v10.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.v10.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 v10 account database: " old-realm new-realm)
(message/migration old-realm new-realm))

View File

@ -1,52 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v10.message
(:require [taoensso.timbre :as log]
[goog.object :as object]
[clojure.string :as str]))
(def schema {:name :message
:primaryKey :message-id
:properties {:message-id :string
:from :string
:to {:type :string
:optional true}
:group-id {: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}
:same-author :bool
:same-direction :bool
:preview {:type :string
:optional true}
: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}}})
(defn migration [old-realm new-realm]
(log/debug "migrating message schema v10")
(let [messages (.objects new-realm "message")]
(dotimes [i (.-length messages)]
(let [message (aget messages i)
content (object/get message "content")
type (object/get message "content-type")]
(when (and (or (= type "wallet-command")
(= type "wallet-request")
(= type "command")
(= type "command-request"))
(or (> (str/index-of content "command=send") -1)
(> (str/index-of content "command=request") -1)))
(aset message "show?" false))))))

View File

@ -1,50 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v11.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 :list
:objectType :chat-contact}
:unremovable? {:type :bool
:default false}
: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}
:last-message-id :string
:message-overhead {:type :int
:default 0}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:contact-info {:type :string
:optional true}
:debug? {:type :bool
:default false}
:public? {:type :bool
:default false}}})
(defn migration [old-realm new-realm]
(log/debug "migrating chat schema v11")
;; make sure that console chat has `:unremovable?` set to true
(when-let [console-chat (-> new-realm
(.objects "chat")
(.filtered "chat-id = \"console\"")
(aget 0))]
(aset console-chat "unremovable?" true)))

View File

@ -1,39 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v11.core
(:require [status-im.data-store.realm.schemas.account.v11.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.v10.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 v11 account database: " old-realm new-realm)
(chat/migration old-realm new-realm))

View File

@ -1,39 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v12.core
(:require [status-im.data-store.realm.schemas.account.v11.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.v10.message :as message]
[status-im.data-store.realm.schemas.account.v12.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 v12 account database: " old-realm new-realm)
(chat/migration old-realm new-realm))

View File

@ -1,37 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v12.pending-message
(:require [goog.object :as object]
[taoensso.timbre :as log]))
(def schema {:name :pending-message
:primaryKey :id
:properties {:id :string
:message-id :string
:chat-id {:type :string
:optional true}
:ack? :bool
:requires-ack? :bool
:sig :string
:pub-key {:type :string
:optional true}
:sym-key-id {:type :string
:optional true}
:to {:type :string
:optional true}
:payload :string
:type :string
:topic :string
:attempts :int
:was-sent? :bool}})
(defn migration [old-realm new-realm]
(log/debug "migrating pending-message schema v12")
(let [messages (.objects old-realm "pending-message")
new-messages (.objects new-realm "pending-message")]
(dotimes [i (.-length messages)]
(let [message (aget messages i)
new-message (aget new-messages i)
key-type (object/get message "key-type")
key (object/get message "key")]
(if (= key-type "sym")
(aset new-message "sym-key-id" key)
(aset new-message "pub-key" key))))))

View File

@ -1,40 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v13.core
(:require [status-im.data-store.realm.schemas.account.v11.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.v10.message :as message]
[status-im.data-store.realm.schemas.account.v12.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]
[status-im.data-store.realm.schemas.account.v13.handler-data :as handler-data]
[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
handler-data/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v13 account database: " old-realm new-realm))

View File

@ -1,8 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v13.handler-data)
(def schema {:name :handler-data
:primaryKey :message-id
:properties {:message-id "string"
:data {:type "string"
:default "{}"}}})

View File

@ -1,34 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v14.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}
:status {:type :string :optional true}
:fcm-token {:type :string :optional true}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:dapp? {:type :bool
:default false}
:dapp-url {:type :string
:optional true}
:bot-url {:type :string
:optional true}
:global-command {:type :command
:optional true}
:commands {:type :list
:objectType :command}
:responses {:type :list
:objectType :command}
:dapp-hash {:type :int
:optional true}
:debug? {:type :bool
:default false}}})

View File

@ -1,40 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v14.core
(:require [status-im.data-store.realm.schemas.account.v11.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.v14.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.v10.message :as message]
[status-im.data-store.realm.schemas.account.v12.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]
[status-im.data-store.realm.schemas.account.v13.handler-data :as handler-data]
[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
handler-data/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v14 account database: " old-realm new-realm))

View File

@ -1,47 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v15.contact
(:require [goog.object :as object]
[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}
:mixable? {:type :bool :default false}
:status {:type :string :optional true}
:fcm-token {:type :string :optional true}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:dapp? {:type :bool
:default false}
:dapp-url {:type :string
:optional true}
:bot-url {:type :string
:optional true}
:global-command {:type :command
:optional true}
:commands {:type :list
:objectType :command}
:responses {:type :list
:objectType :command}
:dapp-hash {:type :int
:optional true}
:debug? {:type :bool
:default false}}})
(defn migration [old-realm new-realm]
(log/debug "migrating contact schema v15")
(let [new-contacts (.objects new-realm "contact")]
(dotimes [i (.-length new-contacts)]
(let [contact (aget new-contacts i)
id (object/get contact "whisper-identity")]
(when (or (= id "mailman")
(= id "transactor-group")
(= id "transactor-personal"))
(aset contact "mixable?" true))))))

View File

@ -1,41 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v15.core
(:require [status-im.data-store.realm.schemas.account.v11.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.v15.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.v10.message :as message]
[status-im.data-store.realm.schemas.account.v12.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.v15.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]
[status-im.data-store.realm.schemas.account.v13.handler-data :as handler-data]
[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
handler-data/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v15 account database: " old-realm new-realm)
(contact/migration old-realm new-realm))

View File

@ -1,15 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v15.request
(:require [taoensso.timbre :as log]))
(def schema {:name :request
:properties {:message-id :string
:chat-id :string
:bot {:type :string
:optional true}
:type :string
:status {:type :string
:default "open"}
:added :date}})
(defn migration [_ _]
(log/debug "migrating request schema"))

View File

@ -1,33 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v16.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}
:mixable? {: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}
:private-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}}})
(defn migration [old-realm new-realm]
(log/debug "migrating contact schema v16"))

View File

@ -1,74 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v16.core
(:require [status-im.data-store.realm.schemas.account.v11.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.v16.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.v10.message :as message]
[status-im.data-store.realm.schemas.account.v12.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.v15.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]
[status-im.data-store.realm.schemas.account.v13.handler-data :as handler-data]
[goog.object :as object]
[taoensso.timbre :as log]
[cljs.reader :as reader]))
(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
handler-data/schema])
(defn chat-by-id [realm chat-id]
(some-> realm
(.objects "chat")
(.filtered (str "chat-id = \"" chat-id "\""))
(aget 0)))
(defn migrate-commands [realm content-type]
(some-> realm
(.objects "message")
(.filtered (str "content-type = \"" content-type "\""))
(.map (fn [object _ _]
(let [group-id (object/get object "group-id")
{:keys [bot] :as content} (reader/read-string (object/get object "content"))]
(when-not bot
(let [chat-id (object/get object "chat-id")
chat (chat-by-id realm chat-id)
group? (object/get chat "group-chat")
bot-name (if group?
"transactor-group"
"transactor-personal")
content' (assoc content :bot bot-name)]
(aset object "content" (pr-str content')))))))))
(defn migration [old-realm new-realm]
(log/debug "migrating v16 account database: " old-realm new-realm)
(when-let [wallet-chat (chat-by-id new-realm "wallet")]
(.delete new-realm wallet-chat))
(when-let [wallet-contact (some-> new-realm
(.objects "contact")
(.filtered (str "whisper-identity = \"wallet\""))
(aget 0))]
(.delete new-realm wallet-contact))
(migrate-commands new-realm "command-request")
(migrate-commands new-realm "command"))

View File

@ -1,92 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v17.core
(:require [status-im.data-store.realm.schemas.account.v11.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.v16.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.v10.message :as message]
[status-im.data-store.realm.schemas.account.v12.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.v15.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]
[status-im.data-store.realm.schemas.account.v13.handler-data :as handler-data]
[goog.object :as object]
[taoensso.timbre :as log]
[cljs.reader :as reader]))
(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
handler-data/schema])
(defn remove-chat-with-contact! [new-realm whisper-identity]
(when-let [chat-contact (some-> new-realm
(.objects "chat-contact")
(.filtered (str "identity = \"" whisper-identity "\""))
(aget 0))]
(log/debug "v17 Removing chat-contact with contact" (pr-str chat-contact))
(.delete new-realm chat-contact))
(when-let [chat (some-> new-realm
(.objects "chat")
(.filtered (str "chat-id = \"" whisper-identity "\""))
(aget 0))]
(log/debug "v17 Removing chat with contact" (pr-str chat))
(.delete new-realm chat)))
(defn remove-contact! [new-realm whisper-identity]
(when-let [contact (some-> new-realm
(.objects "contact")
(.filtered (str "whisper-identity = \"" whisper-identity "\""))
(aget 0))]
(log/debug "v17 Removing contact" (pr-str contact))
(.delete new-realm contact)))
(defn command-with-wrong-bot? [bot command]
(and
(#{"transactor-personal" "transactor-group"} bot)
(not (#{"send" "request"} command))))
(defn update-commands [new-realm content-type]
(some-> new-realm
(.objects "message")
(.filtered (str "content-type = \"" content-type "\""))
(.map (fn [object _ _]
(let [{:keys [bot command] :as content} (reader/read-string (object/get object "content"))
content' (cond->
content
(= "password" command)
(update :params dissoc :password :password-confirmation)
(command-with-wrong-bot? bot command)
(assoc :bot nil))]
(aset object "content" (pr-str content')))))))
;; NOTE(oskarth): Resets Realm for some dApps to be loaded by default_contacts.json instead.
(defn migration [old-realm new-realm]
(log/debug "migrating v17 account database: " old-realm new-realm)
(doseq [contact-id ["oaken-water-meter" "gnosis" "Commiteth" "melonport" "Etherplay"]]
(remove-chat-with-contact! new-realm contact-id)
(remove-contact! new-realm contact-id))
(update-commands new-realm "command")
(update-commands new-realm "command-request"))

View File

@ -1,41 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v18.core
(:require [status-im.data-store.realm.schemas.account.v11.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.v16.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.v10.message :as message]
[status-im.data-store.realm.schemas.account.v18.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.v15.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]
[status-im.data-store.realm.schemas.account.v13.handler-data :as handler-data]
[taoensso.timbre :as log]
[cljs.reader :as reader]))
(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
handler-data/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v18 account database: " old-realm new-realm))

View File

@ -1,26 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v18.pending-message
(:require [taoensso.timbre :as log]))
(def schema {:name :pending-message
:primaryKey :id
:properties {:id :string
:message-id :string
:chat-id {:type :string
:optional true}
:ack? :bool
:requires-ack? :bool
:sig :string
:pub-key {:type :string
:optional true}
:sym-key-password {:type :string
:optional true}
:to {:type :string
:optional true}
:payload :string
:type :string
:topic :string
:attempts :int
:was-sent? :bool}})
(defn migration [old-realm new-realm]
(log/debug "migrating pending-message schema v18"))

View File

@ -1,39 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v19.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 :list
:objectType :chat-contact}
:unremovable? {:type :bool
:default false}
: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}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:contact-info {:type :string
:optional true}
:debug? {:type :bool
:default false}
:public? {:type :bool
:default false}}})

View File

@ -1,30 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v19.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}
:private-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}}})

View File

@ -1,157 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v19.core
(:require [status-im.data-store.realm.schemas.account.v19.chat :as chat]
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v19.contact :as contact]
[status-im.data-store.realm.schemas.account.v1.discover :as discover]
[status-im.data-store.realm.schemas.account.v19.message :as message]
[status-im.data-store.realm.schemas.account.v12.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.v19.request :as request]
[status-im.data-store.realm.schemas.account.v1.tag :as tag]
[status-im.data-store.realm.schemas.account.v19.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]
[goog.object :as object]
[taoensso.timbre :as log]
[cljs.reader :as reader]))
(def schema [chat/schema
chat-contact/schema
contact/schema
discover/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 remove-console-intro-message! [new-realm]
(when-let [console-intro-message (some-> new-realm
(.objects "message")
(.filtered (str "message-id = \"intro-status\""))
(aget 0))]
(log/debug "v19 Removing console intro message " (pr-str console-intro-message))
(.delete new-realm console-intro-message)))
(defn remove-contact! [new-realm whisper-identity]
(when-let [contact (some-> new-realm
(.objects "contact")
(.filtered (str "whisper-identity = \"" whisper-identity "\""))
(aget 0))]
(log/debug "v19 Removing contact " (pr-str contact))
(.delete new-realm contact)))
(def owner-command->new-props
{;; console commands
["console" "password"] {:content-command-ref ["console" :response 42 "password"]
:content-command-scope-bitmask 42}
["console" "debug"] {:content-command-ref ["console" :command 50 "debug"]
:content-command-scope-bitmask 50}
["console" "phone"] {:content-command-ref ["console" :response 50 "phone"]
:content-command-scope-bitmask 50}
["console" "confirmation-code"] {:content-command-ref ["console" :response 50 "confirmation-code"]
:content-command-scope-bitmask 50}
["console" "faucet"] {:content-command-ref ["console" :command 50 "faucet"]
:content-command-scope-bitmask 50}
;; mailman commands
["mailman" "location"] {:content-command-ref ["mailman" :command 215 "location"]
:content-command-scope-bitmask 215}
;; transactor personal
["transactor-personal" "send"] {:content-command-ref ["transactor" :command 83 "send"]
:content-command-scope-bitmask 83
:bot "transactor"}
["transactor-personal" "request"] {:content-command-ref ["transactor" :command 83 "request"]
:content-command-scope-bitmask 83
:bot "transactor"}
;; transactor group
["transactor-group" "send"] {:content-command-ref ["transactor" :command 85 "send"]
:content-command-scope-bitmask 85
:bot "transactor"}
["transactor-group" "request"] {:content-command-ref ["transactor" :command 85 "request"]
:content-command-scope-bitmask 85
:bot "transactor"}})
(def console-requests->new-props
{;; console
["password"] {:content-command-ref ["console" :response 42 "password"]}
["phone"] {:content-command-ref ["console" :response 50 "phone"]}
["confirmation-code"] {:content-command-ref ["console" :response 50 "confirmation-code"]}})
(def transactor-requests->new-props
{;; former transactor-personal request
["send" 1] {:content-command-ref ["transactor" :response 83 "send"]
:content-command-scope-bitmask 83
:bot "transactor"}
;; former transactor-group request
["send" 2] {:content-command-ref ["transactor" :response 85 "send"]
:content-command-scope-bitmask 85
:bot "transactor"}})
(defn update-commands [selector mapping new-realm content-type]
(some-> new-realm
(.objects "message")
(.filtered (str "content-type = \"" content-type "\""))
(.map (fn [object _ _]
(let [content (reader/read-string (object/get object "content"))
new-props (get mapping (selector content))
new-content (merge content new-props)]
(log/debug "migrating v19 command/request database, updating: " content " with: " new-props)
(aset object "content" (pr-str new-content)))))))
(defn update-message-statuses [new-realm]
(let [status-ids (atom #{})]
(some-> new-realm
(.objects "message")
(.map (fn [msg _ _]
(let [message-id (object/get msg "message-id")
chat-id (object/get msg "chat-id")
from (object/get msg "from")
msg-status (object/get msg "message-status")
statuses (object/get msg "user-statuses")]
(when statuses
(.map statuses (fn [status _ _]
(let [status-id (str message-id "-" from)]
(if (@status-ids status-id)
(.delete new-realm status)
(do
(swap! status-ids conj status-id)
(aset status "status-id" status-id)
(aset status "message-id" message-id)
(aset status "chat-id" chat-id))))))
(let [sender (or from "anonymous")
sender-status (str message-id "-" sender)
new-status (or msg-status (if (= "console" chat-id)
"seen"
"received"))]
(when-not (@status-ids sender-status)
(.push statuses (clj->js {"status-id" sender-status
"message-id" message-id
"chat-id" chat-id
"status" new-status
"whisper-identity" sender})))))))))))
(defn delete-orphaned-statuses [new-realm]
(let [id-seq (atom 0)]
(some-> new-realm
(.objects "user-status")
(.map (fn [status _ _]
;; orphaned statues, status-id must be set to some unique value, as realm complains when they are deleted
(when (clojure.string/blank? (object/get status "status-id"))
(log/debug "Setting unique id for orphaned status")
(aset status "status-id" (str (swap! id-seq inc) "-deleted"))))))))
(defn migration [old-realm new-realm]
(log/debug "migrating v19 account database: " old-realm new-realm)
(remove-contact! new-realm "transactor-personal")
(remove-contact! new-realm "transactor-group")
(remove-console-intro-message! new-realm)
(update-commands (juxt :bot :command) owner-command->new-props new-realm "command")
(update-commands (juxt :command) console-requests->new-props new-realm "command-request")
(update-commands (juxt :command (comp count :prefill)) transactor-requests->new-props new-realm "command-request")
(update-message-statuses new-realm)
(delete-orphaned-statuses new-realm))

View File

@ -1,30 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v19.message)
(def schema {:name :message
:primaryKey :message-id
:properties {:message-id :string
:from :string
:to {:type :string
:optional true}
:group-id {: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}}})

View File

@ -1,8 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v19.request)
(def schema {:name :request
:properties {:message-id :string
:chat-id :string
:response :string
:status {:type :string
:default "open"}}})

View File

@ -1,12 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v19.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}})

View File

@ -1,38 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v2.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 :list
:objectType :chat-contact}
: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}
:last-message-id :string
:message-overhead {:type :int
:default 0}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:contact-info {:type :string
:optional true}}})
(defn migration [old-realm new-realm]
(log/debug "migrating chat schema v2"))

View File

@ -1,26 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v2.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}
:status {:type "string" :optional true}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:dapp? {:type :bool
:default false}
:dapp-url {:type :string
:optional true}
:dapp-hash {:type :int
:optional true}}})
(defn migration [old-realm new-realm]
(log/debug "migrating contact schema v2"))

View File

@ -1,32 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v2.core
(:require [status-im.data-store.realm.schemas.account.v2.chat :as chat]
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v1.command :as command]
[status-im.data-store.realm.schemas.account.v2.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.v1.message :as message]
[status-im.data-store.realm.schemas.account.v1.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]
[taoensso.timbre :as log]))
(def schema [chat/schema
chat-contact/schema
command/schema
contact/schema
discover/schema
kv-store/schema
message/schema
pending-message/schema
processed-message/schema
request/schema
tag/schema
user-status/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v2 account database: " old-realm new-realm)
(chat/migration old-realm new-realm)
(contact/migration old-realm new-realm))

View File

@ -1,31 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v20.core
(:require [status-im.data-store.realm.schemas.account.v19.chat :as chat]
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v19.contact :as contact]
[status-im.data-store.realm.schemas.account.v20.discover :as discover]
[status-im.data-store.realm.schemas.account.v19.message :as message]
[status-im.data-store.realm.schemas.account.v12.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.v19.request :as request]
[status-im.data-store.realm.schemas.account.v19.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]
[cljs.reader :as reader]))
(def schema [chat/schema
chat-contact/schema
contact/schema
discover/schema
message/schema
pending-message/schema
processed-message/schema
request/schema
user-status/schema
contact-group/schema
group-contact/schema
local-storage/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v20 account database: " old-realm new-realm))

View File

@ -1,14 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v20.discover
(:require [taoensso.timbre :as log]))
(def schema {:name :discover
:primaryKey :message-id
:properties {:message-id "string"
:name {:type "string" :optional true}
:status "string"
:whisper-id "string"
:photo-path {:type "string" :optional true}
:created-at {:type "int" :default 0}}})
(defn migration [_ _]
(log/debug "migrating discover schema"))

View File

@ -1,37 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v21.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 :list
:objectType :chat-contact}
:unremovable? {:type :bool
:default false}
: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}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:contact-info {:type :string
:optional true}
:debug? {:type :bool
:default false}
:public? {:type :bool
:default false}}})

View File

@ -1,97 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v21.core
(:require [status-im.data-store.realm.schemas.account.v19.chat :as chat]
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v19.contact :as contact]
[status-im.data-store.realm.schemas.account.v20.discover :as discover]
[status-im.data-store.realm.schemas.account.v19.message :as message]
[status-im.data-store.realm.schemas.account.v12.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.v19.request :as request]
[status-im.data-store.realm.schemas.account.v19.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]
[status-im.data-store.realm.schemas.account.v21.browser :as browser]
[taoensso.timbre :as log]
[cljs.reader :as reader]
[clojure.string :as string]))
(def schema [chat/schema
chat-contact/schema
contact/schema
discover/schema
message/schema
pending-message/schema
processed-message/schema
request/schema
user-status/schema
contact-group/schema
group-contact/schema
local-storage/schema
browser/schema])
(defn remove-contact! [new-realm whisper-identity]
(when-let [contact (some-> new-realm
(.objects "contact")
(.filtered (str "whisper-identity = \"" whisper-identity "\""))
(aget 0))]
(log/debug "v21 Removing contact " (pr-str contact))
(.delete new-realm contact)))
(defn remove-location-messages! [old-realm new-realm]
(let [messages (.objects new-realm "message")]
(dotimes [i (.-length messages)]
(let [message (aget messages i)
content (aget message "content")
type (aget message "content-type")]
(when (and (= type "command")
(string/includes? content "command=location"))
(aset message "show?" false))))))
(defn remove-phone-messages! [old-realm new-realm]
(let [messages (.objects new-realm "message")]
(dotimes [i (.-length messages)]
(let [message (aget messages i)
content (aget message "content")
type (aget message "content-type")]
(when (and (= type "command")
(string/includes? content "command=phone"))
(aset message "show?" false))))))
(defn chat-by-id [chats chat-id]
(some-> chats
(.filtered (str "chat-id = \"" chat-id "\""))
(aget 0)))
(defn contact-by-id [contacts contact-id]
(some-> contacts
(.filtered (str "whisper-identity = \"" contact-id "\""))
(aget 0)))
(defn messages-by-chat-id [messages chat-id]
(some-> messages
(.filtered (str "chat-id = \"" chat-id "\""))))
(defn remove-dapp! [realm dapp]
(let [contacts (.objects realm "contact")
chats (.objects realm "chat")
messages (.objects realm "message")]
(when-let [contact (contact-by-id contacts dapp)]
(.delete realm contact)
(when-let [chat (chat-by-id chats dapp)]
(.delete realm chat)
(when-let [messages (messages-by-chat-id messages dapp)]
(.delete realm messages))))))
(defn clean-dapps! [realm]
(let [dapps #{"bchat" "Dentacoin" "gnosis" "melonport" "oaken-water-meter"
"Ethcro" "Augur" "mkr-market"}]
(doseq [dapp dapps]
(remove-dapp! realm dapp))))
(defn migration [old-realm new-realm]
(log/debug "migrating v21 account database: " old-realm new-realm)
(remove-contact! new-realm "browse")
(remove-location-messages! old-realm new-realm)
(remove-phone-messages! old-realm new-realm)
(clean-dapps! new-realm))

View File

@ -1,37 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v22.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 :list
:objectType :chat-contact}
:unremovable? {:type :bool
:default false}
: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}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:contact-info {:type :string
:optional true}
:debug? {:type :bool
:default false}
:public? {:type :bool
:default false}}})

View File

@ -1,36 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v22.core
(:require [status-im.data-store.realm.schemas.account.v22.chat :as chat]
[status-im.data-store.realm.schemas.account.v22.transport :as transport]
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v19.contact :as contact]
[status-im.data-store.realm.schemas.account.v20.discover :as discover]
[status-im.data-store.realm.schemas.account.v19.message :as message]
[status-im.data-store.realm.schemas.account.v12.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.v19.request :as request]
[status-im.data-store.realm.schemas.account.v19.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]
[status-im.data-store.realm.schemas.account.v21.browser :as browser]
[taoensso.timbre :as log]
[cljs.reader :as reader]
[clojure.string :as string]))
(def schema [chat/schema
chat-contact/schema
transport/schema
contact/schema
discover/schema
message/schema
pending-message/schema
processed-message/schema
request/schema
user-status/schema
contact-group/schema
group-contact/schema
local-storage/schema
browser/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v22 account database: " old-realm new-realm))

View File

@ -1,35 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v23.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 :list
:objectType :chat-contact}
:unremovable? {:type :bool
:default false}
: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}}})

View File

@ -1,28 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v23.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}}})

View File

@ -1,62 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v23.core
(:require [status-im.data-store.realm.schemas.account.v23.chat :as chat]
[status-im.data-store.realm.schemas.account.v22.transport :as transport]
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v23.contact :as contact]
[status-im.data-store.realm.schemas.account.v20.discover :as discover]
[status-im.data-store.realm.schemas.account.v23.message :as message]
[status-im.data-store.realm.schemas.account.v19.request :as request]
[status-im.data-store.realm.schemas.account.v19.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]
[status-im.data-store.realm.schemas.account.v21.browser :as browser]
[goog.object :as object]
[taoensso.timbre :as log]
[cljs.reader :as reader]
[clojure.string :as string]))
(def schema [chat/schema
chat-contact/schema
transport/schema
contact/schema
discover/schema
message/schema
request/schema
user-status/schema
contact-group/schema
group-contact/schema
local-storage/schema
browser/schema])
(defn update-new-message [new-realm message-id to-clock-value from-clock-value]
(when-let [message (some-> new-realm
(.objects "message")
(.filtered (str "message-id = \"" message-id "\""))
(aget 0))]
(aset message "to-clock-value" to-clock-value)
(aset message "from-clock-value" from-clock-value)))
(defn update-chat-messages [old-realm new-realm chat-id]
(let [from-clock-value (atom 0)
to-clock-value (atom 0)]
(some-> old-realm
(.objects "message")
(.filtered (str "chat-id = \"" chat-id "\""))
(.sorted "clock-value" false)
(.map (fn [message _ _]
(let [message-id (object/get message "message-id")
outgoing? (boolean (object/get message "outgoing"))]
(if outgoing?
(update-new-message new-realm message-id (swap! to-clock-value inc) @from-clock-value)
(update-new-message new-realm message-id @to-clock-value (swap! from-clock-value inc)))))))))
(defn update-chats [old-realm new-realm]
(some-> new-realm
(.objects "chat")
(.map (fn [chat _ _]
(update-chat-messages old-realm new-realm (object/get chat "chat-id"))))))
(defn migration [old-realm new-realm]
(log/debug "migrating v23 account database: " old-realm new-realm)
(update-chats old-realm new-realm))

View File

@ -1,30 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v23.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}
:from-clock-value {:type :int
:default 0}
:to-clock-value {:type :int
:default 0}
:show? {:type :bool
:default true}}})

View File

@ -1,40 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v3.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 :list
:objectType :chat-contact}
: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}
:last-message-id :string
:message-overhead {:type :int
:default 0}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:contact-info {:type :string
:optional true}
:debug? {:type :bool
:default false}}})
(defn migration [old-realm new-realm]
(log/debug "migrating chat schema v3"))

View File

@ -1,28 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v3.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}
:status {:type "string" :optional true}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:dapp? {:type :bool
:default false}
:dapp-url {:type :string
:optional true}
:dapp-hash {:type :int
:optional true}
:debug? {:type :bool
:default false}}})
(defn migration [old-realm new-realm]
(log/debug "migrating contact schema v3"))

View File

@ -1,32 +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.chat-contact :as chat-contact]
[status-im.data-store.realm.schemas.account.v1.command :as command]
[status-im.data-store.realm.schemas.account.v3.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.v1.message :as message]
[status-im.data-store.realm.schemas.account.v1.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]
[taoensso.timbre :as log]))
(def schema [chat/schema
chat-contact/schema
command/schema
contact/schema
discover/schema
kv-store/schema
message/schema
pending-message/schema
processed-message/schema
request/schema
tag/schema
user-status/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v3 account database: " old-realm new-realm)
(chat/migration old-realm new-realm)
(contact/migration old-realm new-realm))

View File

@ -1,42 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v4.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 :list
:objectType :chat-contact}
: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}
:last-message-id :string
:message-overhead {:type :int
:default 0}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:contact-info {:type :string
:optional true}
:debug? {:type :bool
:default false}
:public? {:type :bool
:default false}}})
(defn migration [old-realm new-realm]
(log/debug "migrating chat schema v4"))

View File

@ -1,32 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v4.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.v1.command :as command]
[status-im.data-store.realm.schemas.account.v3.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.v1.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]
[taoensso.timbre :as log]))
(def schema [chat/schema
chat-contact/schema
command/schema
contact/schema
discover/schema
kv-store/schema
message/schema
pending-message/schema
processed-message/schema
request/schema
tag/schema
user-status/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v4 account database: " old-realm new-realm)
(chat/migration old-realm new-realm)
(contact/migration old-realm new-realm))

View File

@ -1,38 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v4.message
(:require [taoensso.timbre :as log]))
(def schema {:name :message
:primaryKey :message-id
:properties {:message-id :string
:from :string
:to {:type :string
:optional true}
:group-id {: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}
:same-author :bool
:same-direction :bool
:preview {:type :string
:optional true}
: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}}})
(defn migration [_ _]
(log/debug "migrating message schema"))

View File

@ -1,36 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v5.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.v1.command :as command]
[status-im.data-store.realm.schemas.account.v3.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.v1.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]
[taoensso.timbre :as log]))
(def schema [chat/schema
chat-contact/schema
command/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])
(defn migration [old-realm new-realm]
(log/debug "migrating v5 account database: " old-realm new-realm)
(chat/migration old-realm new-realm)
(contact/migration old-realm new-realm))

View File

@ -1,8 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v5.group-contact
(:require [taoensso.timbre :as log]))
(def schema {:name :group-contact
:properties {:identity "string"}})
(defn migration [_ _]
(log/debug "migrating group-contact schema v5"))

View File

@ -1,26 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v6.command
(:require [taoensso.timbre :as log]))
(def schema {:name :command
:properties {:description {:type :string
:optional true}
:color {:type :string
:optional true}
:name {:type :string}
:icon {:type :string
:optional true}
:params {:type :list
:objectType :command-parameter}
:title {:type :string
:optional true}
:has-handler {:type :bool
:default true}
:fullscreen {:type :bool
:default true}
:suggestions-trigger {:type :string
:default "on-change"}
:sequential-params {:type :bool
:default false}}})
(defn migration [old-realm new-realm]
(log/debug "migrating chat-contact schema v6"))

View File

@ -1,9 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v6.command-parameter
(:require [taoensso.timbre :as log]))
(def schema {:name :command-parameter
:properties {:name {:type :string}
:type {:type :string}}})
(defn migration [_ _]
(log/debug "migrating command-parameter schema"))

View File

@ -1,47 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v6.contact
(:require [goog.object :as object]
[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}
:status {:type :string :optional true}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:dapp? {:type :bool
:default false}
:dapp-url {:type :string
:optional true}
:bot-url {:type :string
:optional true}
:global-command {:type :command
:optional true}
:commands {:type :list
:objectType :command}
:responses {:type :list
:objectType :command}
:dapp-hash {:type :int
:optional true}
:debug? {:type :bool
:default false}}})
(defn migration [old-realm new-realm]
(log/debug "migrating contact schema v6")
(let [new-contacts (.objects new-realm "contact")]
(dotimes [i (.-length new-contacts)]
(let [contact (aget new-contacts i)
id (object/get contact "whisper-identity")]
(when (= id "console")
(log/debug (js->clj contact))
(aset contact "dapp-url" nil)
(aset contact "bot-url" "local://console-bot"))
(when (= id "wallet")
(aset contact "dapp-url" "https://status.im/dapps/wallet/"))))))

View File

@ -1,38 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v6.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.v6.command-parameter :as command-parameter]
[status-im.data-store.realm.schemas.account.v6.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.v1.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]
[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])
(defn migration [old-realm new-realm]
(log/debug "migrating v6 account database: " old-realm new-realm)
(chat/migration old-realm new-realm)
(contact/migration old-realm new-realm))

View File

@ -1,47 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v7.contact
(:require [goog.object :as object]
[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}
:status {:type :string :optional true}
:public-key {:type :string
:optional true}
:private-key {:type :string
:optional true}
:unremovable? {:type :bool
:default false}
:dapp? {:type :bool
:default false}
:dapp-url {:type :string
:optional true}
:bot-url {:type :string
:optional true}
:global-command {:type :command
:optional true}
:commands {:type :list
:objectType :command}
:responses {:type :list
:objectType :command}
:dapp-hash {:type :int
:optional true}
:debug? {:type :bool
:default false}}})
(defn migration [old-realm new-realm]
(log/debug "migrating contact schema v7")
(let [new-contacts (.objects new-realm "contact")]
(dotimes [i (.-length new-contacts)]
(let [contact (aget new-contacts i)
id (object/get contact "whisper-identity")]
(when (or (= id "console")
(= id "wallet")
(= id "browse"))
(aset contact "unremovable?" true))))))

View File

@ -1,37 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v7.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.v6.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]
[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])
(defn migration [old-realm new-realm]
(log/debug "migrating v7 account database: " old-realm new-realm)
(contact/migration old-realm new-realm))

View File

@ -1,27 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v7.pending-message
(:require [taoensso.timbre :as log]))
(def schema {:name :pending-message
:primaryKey :id
:properties {:id :string
:message-id :string
:chat-id {:type :string
:optional true}
:ack? :bool
:requires-ack? :bool
:sig :string
:key :string
:key-type :string
:to {:type :string
:optional true}
:payload :string
:type :string
:topic :string
:attempts :int
:was-sent? :bool}})
(defn migration [_ new-realm]
(log/debug "migrating pending-message schema v7")
(let [new-contacts (.objects new-realm "contact")]
(dotimes [i (.-length new-contacts)]
(.delete new-realm (aget new-contacts i)))))

View File

@ -1,38 +0,0 @@
(ns status-im.data-store.realm.schemas.account.v8.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.v6.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))

View File

@ -1,8 +0,0 @@
(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

@ -1,50 +0,0 @@
(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]
[goog.object :as object]
[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 (object/get command "name")
command-title (object/get 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"))))))

View File

@ -1,39 +1,7 @@
(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]))
(:require [status-im.data-store.realm.schemas.base.v1.core :as v1]))
;; put schemas ordered by version
(def schemas [{:schema v1/schema
:schemaVersion 1
:migration v1/migration}
{:schema v2/schema
:schemaVersion 2
:migration v2/migration}
{:schema v3/schema
:schemaVersion 3
:migration v3/migration}
{:schema v4/schema
:schemaVersion 4
:migration v4/migration}
{:schema v5/schema
:schemaVersion 5
:migration v5/migration}
{:schema v6/schema
:schemaVersion 6
:migration v6/migration}
{:schema v7/schema
:schemaVersion 7
:migration v7/migration}
{:schema v8/schema
:schemaVersion 8
:migration v8/migration}
{:schema v9/schema
:schemaVersion 9
:migration v9/migration}])
:migration v1/migration}])

View File

@ -1,23 +1,25 @@
(ns status-im.data-store.realm.schemas.base.v1.account
(:require [taoensso.timbre :as log]))
(ns status-im.data-store.realm.schemas.base.v1.account)
(def schema {:name :account
:primaryKey :address
:properties {:address :string
:public-key :string
:updates-public-key {:type :string
:optional true}
:updates-private-key {:type :string
:optional true}
:name {:type :string :optional true}
:phone {: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}})
(defn migration [_ _]
(log/debug "migrating account schema"))
:network :string
:networks {:type :list
:objectType :network}
:wnode :string
:settings {:type :string}
:sharing-usage-data? {:type :bool :default false}
:dev-mode? {:type :bool :default false}
:seed-backed-up? {:type :bool :default false}}})

View File

@ -1,12 +1,10 @@
(ns status-im.data-store.realm.schemas.base.v1.core
(:require [status-im.data-store.realm.schemas.base.v1.account :as account]
[status-im.data-store.realm.schemas.base.v1.kv-store :as kv-store]
(: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 [account/schema
kv-store/schema])
(def schema [network/schema
account/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v1 base database: " old-realm new-realm)
(account/migration old-realm new-realm)
(kv-store/migration old-realm new-realm))
(log/debug "migrating base database v1: " old-realm new-realm))

View File

@ -1,10 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v1.kv-store
(:require [taoensso.timbre :as log]))
(def schema {:name :kv-store
:primaryKey :key
:properties {:key "string"
:value "string"}})
(defn migration [_ _]
(log/debug "migrating kv-store schema"))

View File

@ -1,4 +1,4 @@
(ns status-im.data-store.realm.schemas.base.v4.network
(ns status-im.data-store.realm.schemas.base.v1.network
(:require [taoensso.timbre :as log]))
(def schema {:name :network
@ -10,6 +10,3 @@
:optional true}
:rpc-url {:type :string
:optional true}}})
(defn migration [old-realm new-realm]
(log/debug "migrating network schema v4"))

View File

@ -1,25 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v2.account
(:require [taoensso.timbre :as log]))
(def schema {:name :account
:primaryKey :address
:properties {:address :string
:public-key :string
:updates-public-key {:type :string
:optional true}
:updates-private-key {:type :string
:optional true}
:name {:type :string :optional true}
:phone {:type :string :optional true}
:email {:type :string :optional true}
:status {:type :string :optional true}
:debug? {:type :bool :default false}
:photo-path :string
:last-updated {:type :int :default 0}
:signed-up? {:type :bool
:default false}
:network :string}})
(defn migration [_ _]
(log/debug "migrating account schema"))

View File

@ -1,13 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v2.core
(:require [status-im.data-store.realm.schemas.base.v2.account :as account]
[status-im.data-store.realm.schemas.base.v1.kv-store :as kv-store]
[taoensso.timbre :as log]))
(def schema [account/schema
kv-store/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v2 base database: " old-realm new-realm)
(account/migration old-realm new-realm)
(kv-store/migration old-realm new-realm))

View File

@ -1,35 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v3.account
(:require [goog.object :as object]
[taoensso.timbre :as log]
[status-im.utils.signing-phrase.core :as signing-phrase]))
(def schema {:name :account
:primaryKey :address
:properties {:address :string
:public-key :string
:updates-public-key {:type :string
:optional true}
:updates-private-key {:type :string
:optional true}
:name {:type :string :optional true}
:phone {: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}
:last-updated {:type :int :default 0}
:signed-up? {:type :bool
:default false}
:network :string}})
(defn migration [_old-realm new-realm]
(log/debug "migrating account schema v3")
(let [accounts (.objects new-realm "account")]
(dotimes [i (.-length accounts)]
(let [account (aget accounts i)
phrase (object/get account "signing-phrase")]
(when (empty? phrase)
(log/debug (js->clj account))
(aset account "signing-phrase" (signing-phrase/generate)))))))

View File

@ -1,12 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v3.core
(:require [status-im.data-store.realm.schemas.base.v3.account :as account]
[status-im.data-store.realm.schemas.base.v1.kv-store :as kv-store]
[taoensso.timbre :as log]))
(def schema [account/schema
kv-store/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v3 base database: " old-realm new-realm)
(account/migration old-realm new-realm))

View File

@ -1,32 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v4.account
(:require [taoensso.timbre :as log]
[status-im.constants :as constants]))
(def schema {:name :account
:primaryKey :address
:properties {:address :string
:public-key :string
:updates-public-key {:type :string
:optional true}
:updates-private-key {:type :string
:optional true}
:name {:type :string :optional true}
:phone {: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}
:last-updated {:type :int :default 0}
:signed-up? {:type :bool
:default false}
:network :string
:networks {:type :list
:objectType :network}}})
(defn migration [_old-realm new-realm]
(log/debug "migrating account schema v4")
(let [accounts (.objects new-realm "account")]
(dotimes [i (.-length accounts)]
(let [account (aget accounts i)]
(aset account "network" constants/default-network)))))

View File

@ -1,14 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v4.core
(:require [status-im.data-store.realm.schemas.base.v4.network :as network]
[status-im.data-store.realm.schemas.base.v4.account :as account]
[taoensso.timbre :as log]))
(def schema [network/schema
account/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v4 base database: " old-realm new-realm)
(network/migration old-realm new-realm)
(account/migration old-realm new-realm))

View File

@ -1,29 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v5.account
(:require [taoensso.timbre :as log]))
(def schema {:name :account
:primaryKey :address
:properties {:address :string
:public-key :string
:updates-public-key {:type :string
:optional true}
:updates-private-key {:type :string
:optional true}
:name {:type :string :optional true}
:phone {: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}
:last-updated {:type :int :default 0}
:signed-up? {:type :bool
:default false}
:network :string
:networks {:type :list
:objectType :network}
:settings {:type :string}}})
(defn migration [old-realm new-realm]
(log/debug "migrating account schema v5"))

View File

@ -1,13 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v5.core
(:require [status-im.data-store.realm.schemas.base.v4.network :as network]
[status-im.data-store.realm.schemas.base.v5.account :as account]
[taoensso.timbre :as log]))
(def schema [network/schema
account/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v5 base database: " old-realm new-realm)
(account/migration old-realm new-realm))

View File

@ -1,33 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v6.account
(:require [taoensso.timbre :as log]
[status-im.constants :as constants]))
(def schema {:name :account
:primaryKey :address
:properties {:address :string
:public-key :string
:updates-public-key {:type :string
:optional true}
:updates-private-key {:type :string
:optional true}
: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}
:last-updated {:type :int :default 0}
:signed-up? {:type :bool
:default false}
:network :string
:networks {:type :list
:objectType :network}
:wnode :string
:settings {:type :string}}})
(defn migration [_old-realm new-realm]
(log/debug "migrating account schema v6")
(let [accounts (.objects new-realm "account")]
(dotimes [i (.-length accounts)]
(let [account (aget accounts i)]
(aset account "wnode" constants/default-wnode)))))

View File

@ -1,11 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v6.core
(:require [status-im.data-store.realm.schemas.base.v4.network :as network]
[status-im.data-store.realm.schemas.base.v6.account :as account]
[taoensso.timbre :as log]))
(def schema [network/schema
account/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v6 base database: " old-realm new-realm)
(account/migration old-realm new-realm))

View File

@ -1,26 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v7.account)
(def schema {:name :account
:primaryKey :address
:properties {:address :string
:public-key :string
:updates-public-key {:type :string
:optional true}
:updates-private-key {:type :string
:optional true}
: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}
: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}
:wnode :string
:settings {:type :string}
:sharing-usage-data? {:type :bool :default false}}})

View File

@ -1,10 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v7.core
(:require [status-im.data-store.realm.schemas.base.v4.network :as network]
[status-im.data-store.realm.schemas.base.v7.account :as account]
[taoensso.timbre :as log]))
(def schema [network/schema
account/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v7 base database: " old-realm new-realm))

View File

@ -1,29 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v8.account)
(def schema {:name :account
:primaryKey :address
:properties {:address :string
:public-key :string
:updates-public-key {:type :string
:optional true}
:updates-private-key {:type :string
:optional true}
: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}
:wnode :string
:settings {:type :string}
:sharing-usage-data? {:type :bool :default false}
:dev-mode? {:type :bool :default false}
:seed-backed-up? {:type :bool :default false}}})

View File

@ -1,10 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v8.core
(:require [status-im.data-store.realm.schemas.base.v4.network :as network]
[status-im.data-store.realm.schemas.base.v8.account :as account]
[taoensso.timbre :as log]))
(def schema [network/schema
account/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating v8 base database: " old-realm new-realm))

View File

@ -1,25 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v9.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}
:wnode :string
:settings {:type :string}
:sharing-usage-data? {:type :bool :default false}
:dev-mode? {:type :bool :default false}
:seed-backed-up? {:type :bool :default false}}})

View File

@ -1,10 +0,0 @@
(ns status-im.data-store.realm.schemas.base.v9.core
(:require [status-im.data-store.realm.schemas.base.v4.network :as network]
[status-im.data-store.realm.schemas.base.v9.account :as account]
[taoensso.timbre :as log]))
(def schema [network/schema
account/schema])
(defn migration [old-realm new-realm]
(log/debug "migrating 9 base database: " old-realm new-realm))