fix user-statuses after migration from #6722

This commit is contained in:
Roman Volosovskyi 2018-11-22 19:46:52 +02:00
parent 719b9f199c
commit 6ca3933b71
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 22 additions and 3 deletions

View File

@ -340,4 +340,7 @@
:migration migrations/v24} :migration migrations/v24}
{:schema v25 {:schema v25
:schemaVersion 25 :schemaVersion 25
:migration migrations/v25}]) :migration migrations/v25}
{:schema v25
:schemaVersion 26
:migration migrations/v26}])

View File

@ -203,8 +203,8 @@
(let [user-status (aget user-statuses i) (let [user-status (aget user-statuses i)
message-id (aget user-status "message-id") message-id (aget user-status "message-id")
new-message-id (get @old-ids->new-ids message-id) new-message-id (get @old-ids->new-ids message-id)
whisper-id (aget user-status "whisper-identity") public-key (aget user-status "public-key")
new-status-id (str new-message-id "-" whisper-id)] new-status-id (str new-message-id "-" public-key)]
(if (contains? @updated-message-statuses-ids new-status-id) (if (contains? @updated-message-statuses-ids new-status-id)
(vswap! statuses-to-be-deleted conj user-status) (vswap! statuses-to-be-deleted conj user-status)
(do (do
@ -214,3 +214,19 @@
(doseq [status @statuses-to-be-deleted] (doseq [status @statuses-to-be-deleted]
(.delete new-realm status)))) (.delete new-realm status))))
(defn v26 [old-realm new-realm]
(let [user-statuses (.objects new-realm "user-status")]
(dotimes [i (.-length user-statuses)]
(let [user-status (aget user-statuses i)
status-id (aget user-status "message-id")
message-id (aget user-status "message-id")
public-key (aget user-status "public-key")
new-status-id (str message-id "-" public-key)]
(when (and (= "-" (last status-id)))
(if (.objectForPrimaryKey
new-realm
"user-status"
new-status-id)
(.delete new-realm user-status)
(aset user-status "status-id" new-status-id)))))))