修復 WeKan 無法顯示 Board 內容的問題

淺羽的團隊內部啓用 WeKan 作爲 Trello 的替代品管理項目進度和日程。早晨經過 Dimlao 的一番操作,Board 的內容突然無法正常顯示。嘗試更新、重啓 App 甚至修復 MongoDB 都無效。在我們都快放棄、準備重建整個 Board 的時候,通過扒 GitHub 的 Issue,發現在 #1768#1703 中有提到:

Same issue here – when you move a card with a custom field to a board without the custom field, the target board is not longer loading.

一陣沉默後,Dimlao 說道:

…… 等等,是不是因为我删除了那个 custom field ……

之前的一些 Card 確實有加入過 Custom Field,但是因爲需要手動在所有卡片中加入太過於麻煩,最後放棄不用了。於是 Dimlao 遵循正常人類的邏輯,在沒有清理乾淨卡片的情況下,直接刪除了 Custom Field,導致慘劇的發生。

(後面還有:覺得還可以再搶救一下)

那怎麼辦?修資料庫吧。先開一個 Mongo,然後看看所在的資料庫並且選擇它:

> show dbs
local 0.000GB
wekan 0.002GB

>use wekan
switched to db wekan

接下來需要做的事情很簡單:找到被刪除的 Custom Field,並且把它從 Card 記錄寄刪除掉。WeKan 裏都是按照 id 來記錄的,所以需要先去查到 Custom Field 的 id,然後查找有 customFields 的 id 匹配的 Card 並且刪掉記錄。

> show collections
accountSettings                                                                                                                                                                                                     
activities                                                                                                                                                                                                          
announcements                                                                                                                                                                                                       
boards                                                                                                                                                                                                              
card_comments                                                                                                                                                                                                       
cards                                                                                                                                                                                                               
cfs._tempstore.chunks                                                                                                                                                                                               
cfs.avatars.filerecord                                                                                                                                                                                              
cfs_gridfs._tempstore.chunks                                                                                                                                                                                        
cfs_gridfs._tempstore.files                                                                                                                                                                                         
cfs_gridfs.avatars.chunks                                                                                                                                                                                           
cfs_gridfs.avatars.files                                                                                                                                                                                            
checklistItems                                                                                                                                                                                                      
checklists                                                                                                                                                                                                          
customFields                                                                                                                                                                                                        
esCounts                                                                                                                                                                                                            
invitation_codes                                                                                                                                                                                                    
lists                                                                                                                                                                                                               
meteor-migrations
meteor_accounts_loginServiceConfiguration                                                                                                                                                                           
meteor_oauth_pendingCredentials                                                                                                                                                                                     
presences                                                                                                                                                                                                           
settings                                                                                                                                                                                                            
swimlanes
unsaved-edits                                                                                                                                                                                                       
users

按照 WeKan 的資料結構,customFields 集合裏應該就是所有的 Custom Fields 了。然而因爲 Dimlao 已經刪掉了,所以並查不出東西;不過這時候還可以查 Card 裏有哪些記錄,刪掉就是了。

> db.cards.find()
.... , "customFields" : [ { "_id" : "77DLjmk5dN5PnGLEP", "value" : "ZkBnfb" } ],
 "listId" : "6bX74x2s5NTnFpbDQ", "boardId" : "BudzemLxvCxQamTC4", ....

這裏可以得到兩個很重要的訊息:Card 的 Custom Field ID 和 Board 的 ID。接下來指定這兩個 ID 去刪掉 Card 關聯的 Custom Field:

> db.cards.updateMany({boardId:"BudzemLxvCxQamTC4","customFields._id":"77DLjmk5dN5PnGLEP"},{$unset:{customFields:{ "_id" : "77DLjmk5dN5PnGLEP", "value" : "ZkBnfb"} } })
{ "acknowledged" : true, "matchedCount" : 2, "modifiedCount" : 2 }

重新整理看板,就可以顯示出應有的內容了。就是不知道 WeKan 什麼時候官方解決一下這個問題。

Comments

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

To respond on your own website, enter the URL of your response which should contain a link to this post’s permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Find out more about Webmentions.)