mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-15 16:32:40 -05:00
feat: implement backup restoration from old db schemas (#2213)
* Remove some implicit lazy-loads from user serialization * implement full backup restore across different database versions
This commit is contained in:
@@ -78,14 +78,19 @@ class UserBase(MealieModel):
|
||||
can_organize: bool = False
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
class _UserGetter(GetterDict):
|
||||
def get(self, key: Any, default: Any = None) -> Any:
|
||||
# Transform extras into key-value dict
|
||||
if key == "group":
|
||||
value = super().get(key, default)
|
||||
return value.group.name
|
||||
|
||||
@classmethod
|
||||
def getter_dict(cls, name_orm: User):
|
||||
return {
|
||||
**GetterDict(name_orm),
|
||||
"group": name_orm.group.name,
|
||||
}
|
||||
# Keep all other fields as they are
|
||||
else:
|
||||
return super().get(key, default)
|
||||
|
||||
orm_mode = True
|
||||
getter_dict = _UserGetter
|
||||
|
||||
schema_extra = {
|
||||
"example": {
|
||||
|
||||
Reference in New Issue
Block a user