fix ta_config appsettings migration

This commit is contained in:
Simon
2025-03-09 21:04:54 +07:00
parent edaf1cdd7d
commit d4cfb783ef

View File

@@ -168,7 +168,7 @@ class Command(BaseCommand):
) )
return return
if not config: if not config or config == {"status": False}:
self.stdout.write( self.stdout.write(
self.style.SUCCESS(" no config values to migrate") self.style.SUCCESS(" no config values to migrate")
) )
@@ -181,7 +181,7 @@ class Command(BaseCommand):
self.stdout.write( self.stdout.write(
self.style.SUCCESS(" ✓ migrated appconfig to ES") self.style.SUCCESS(" ✓ migrated appconfig to ES")
) )
RedisArchivist().del_message("config") RedisArchivist().del_message("config", save=True)
return return
message = " 🗙 failed to migrate app config" message = " 🗙 failed to migrate app config"
@@ -262,8 +262,8 @@ class Command(BaseCommand):
def _init_app_config(self) -> None: def _init_app_config(self) -> None:
"""init default app config to ES""" """init default app config to ES"""
self.stdout.write("[10] Check AppConfig") self.stdout.write("[10] Check AppConfig")
try: _, status_code = ElasticWrap("ta_config/_doc/appsettings").get()
_ = AppConfig().config if status_code in [200, 201]:
self.stdout.write( self.stdout.write(
self.style.SUCCESS(" skip completed appsettings init") self.style.SUCCESS(" skip completed appsettings init")
) )
@@ -273,15 +273,16 @@ class Command(BaseCommand):
self.style.SUCCESS(f" added new default: {new_default}") self.style.SUCCESS(f" added new default: {new_default}")
) )
except ValueError: return
handler = AppConfig.__new__(AppConfig)
_, status_code = handler.sync_defaults() handler = AppConfig.__new__(AppConfig)
self.stdout.write( _, status_code = handler.sync_defaults()
self.style.SUCCESS(" ✓ Created default appsettings.") self.stdout.write(
) self.style.SUCCESS(" ✓ Created default appsettings.")
self.stdout.write( )
self.style.SUCCESS(f" Status code: {status_code}") self.stdout.write(
) self.style.SUCCESS(f" Status code: {status_code}")
)
def _mig_channel_tags(self) -> None: def _mig_channel_tags(self) -> None:
"""update from v0.4.13 to v0.5.0, migrate incorrect data types""" """update from v0.4.13 to v0.5.0, migrate incorrect data types"""