mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Fix migrations from JSON driver (#3714)
This commit is contained in:
parent
00d20f14b9
commit
a1095285e4
@ -187,11 +187,11 @@ class JsonDriver(BaseDriver):
|
||||
continue
|
||||
if not isinstance(data, dict):
|
||||
continue
|
||||
for cog, inner in data.items():
|
||||
cog_name = _dir.stem
|
||||
for cog_id, inner in data.items():
|
||||
if not isinstance(inner, dict):
|
||||
continue
|
||||
for cog_id in inner:
|
||||
yield cog, cog_id
|
||||
yield cog_name, cog_id
|
||||
|
||||
async def import_data(self, cog_data, custom_group_data):
|
||||
def update_write_data(identifier_data: IdentifierData, _data):
|
||||
|
||||
@ -108,12 +108,9 @@ def get_storage_type():
|
||||
storage = None
|
||||
while storage is None:
|
||||
print()
|
||||
print("Please choose your storage backend (if you're unsure, choose 1).")
|
||||
print("Please choose your storage backend (if you're unsure, just choose 1).")
|
||||
print("1. JSON (file storage, requires no database).")
|
||||
print(
|
||||
"2. PostgreSQL (Requires a database server)"
|
||||
"\n(Warning: You cannot convert postgres instances to other backends yet)"
|
||||
)
|
||||
print("2. PostgreSQL (Requires a database server)")
|
||||
storage = input("> ")
|
||||
try:
|
||||
storage = int(storage)
|
||||
@ -382,7 +379,7 @@ def delete(
|
||||
|
||||
@cli.command()
|
||||
@click.argument("instance", type=click.Choice(instance_list))
|
||||
@click.argument("backend", type=click.Choice(["json"])) # TODO: GH-3115
|
||||
@click.argument("backend", type=click.Choice(["json", "postgres"]))
|
||||
def convert(instance, backend):
|
||||
"""Convert data backend of an instance."""
|
||||
current_backend = get_current_backend(instance)
|
||||
@ -394,8 +391,6 @@ def convert(instance, backend):
|
||||
|
||||
if current_backend == BackendType.MONGOV1:
|
||||
raise RuntimeError("Please see the 3.2 release notes for upgrading a bot using mongo.")
|
||||
elif current_backend == BackendType.POSTGRES: # TODO: GH-3115
|
||||
raise RuntimeError("Converting away from postgres isn't currently supported")
|
||||
else:
|
||||
new_storage_details = asyncio.run(do_migration(current_backend, target))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user