diff --git a/lifecycle/system_migrations/to_0_12.py b/lifecycle/system_migrations/to_0_12.py deleted file mode 100644 index 683c47fa2..000000000 --- a/lifecycle/system_migrations/to_0_12.py +++ /dev/null @@ -1,31 +0,0 @@ -from pickle import loads -from typing import Any # nosec - -from redis import Redis - -from lifecycle.migrate import BaseMigration -from passbook.lib.config import CONFIG - - -class Migration(BaseMigration): - - def __init__(self, cur: Any, con: Any): - super().__init__(cur, con) - self.redis = Redis( - host=CONFIG.y("redis.host"), - port=6379, - db=CONFIG.y("redis.cache_db"), - password=CONFIG.y("redis.password"), - ) - - def needs_migration(self) -> bool: - keys = self.redis.keys(":1:outpost_*") - for key in keys: - value = loads(self.redis.get(key)) # nosec - if isinstance(value, str): - return True - return False - - def run(self): - keys_to_delete = self.redis.keys(":1:outpost_*") - self.redis.delete(*keys_to_delete) diff --git a/passbook/outposts/models.py b/passbook/outposts/models.py index 228c7fdb6..94cf5a605 100644 --- a/passbook/outposts/models.py +++ b/passbook/outposts/models.py @@ -204,7 +204,11 @@ class OutpostState: def for_channel(outpost: Outpost, channel: str) -> "OutpostState": """Get state for a single channel""" key = f"{outpost.state_cache_prefix}_{channel}" - data = cache.get(key, {"uid": channel}) + default_data = {"uid": channel} + data = cache.get(key, default_data) + if isinstance(data, str): + cache.delete(key) + data = default_data state = from_dict(OutpostState, data) state.uid = channel # pylint: disable=protected-access