Here is my code
thread_local! {
static MEMORY_MANAGER: RefCell<MemoryManager<DefaultMemoryImpl>> = RefCell::new(MemoryManager::init(DefaultMemoryImpl::default()));
static USER_STORE: RefCell<StableBTreeMap<
String,
User,
Memory
>> = RefCell::new(
StableBTreeMap::init(
MEMORY_MANAGER.with_borrow(|m| m.get(USER_MEMORY_ID)),
)
);
}
When I made an upgrade the data in USER_STORE is gone. It only work when I put this code in the post_upgrade
USER_STORE.with(|t| {
*t.borrow_mut() = StableBTreeMap::init(
MEMORY_MANAGER.with_borrow(|m| m.get(USER_MEMORY_ID)),
);
});