mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Avoid repeated calls to utc_from_timestamp(0).isoformat() when migrating (#122413)
This commit is contained in:
parent
3dc36cf068
commit
db6704271c
@ -133,10 +133,9 @@ class AreaRegistryStore(Store[AreasRegistryStoreData]):
|
||||
|
||||
if old_minor_version < 7:
|
||||
# Version 1.7 adds created_at and modiefied_at
|
||||
created_at = utc_from_timestamp(0).isoformat()
|
||||
for area in old_data["areas"]:
|
||||
area["created_at"] = area["modified_at"] = utc_from_timestamp(
|
||||
0
|
||||
).isoformat()
|
||||
area["created_at"] = area["modified_at"] = created_at
|
||||
|
||||
if old_major_version > 1:
|
||||
raise NotImplementedError
|
||||
|
@ -87,10 +87,9 @@ class FloorRegistryStore(Store[FloorRegistryStoreData]):
|
||||
if old_major_version == 1:
|
||||
if old_minor_version < 2:
|
||||
# Version 1.2 implements migration and adds created_at and modified_at
|
||||
created_at = utc_from_timestamp(0).isoformat()
|
||||
for floor in old_data["floors"]:
|
||||
floor["created_at"] = floor["modified_at"] = utc_from_timestamp(
|
||||
0
|
||||
).isoformat()
|
||||
floor["created_at"] = floor["modified_at"] = created_at
|
||||
|
||||
return old_data # type: ignore[return-value]
|
||||
|
||||
|
@ -87,10 +87,9 @@ class LabelRegistryStore(Store[LabelRegistryStoreData]):
|
||||
if old_major_version == 1:
|
||||
if old_minor_version < 2:
|
||||
# Version 1.2 implements migration and adds created_at and modified_at
|
||||
created_at = utc_from_timestamp(0).isoformat()
|
||||
for label in old_data["labels"]:
|
||||
label["created_at"] = label["modified_at"] = utc_from_timestamp(
|
||||
0
|
||||
).isoformat()
|
||||
label["created_at"] = label["modified_at"] = created_at
|
||||
|
||||
return old_data # type: ignore[return-value]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user