Fix migrations from JSON driver (#3714)

This commit is contained in:
jack1142 2020-04-27 01:32:52 +02:00 committed by GitHub
parent 00d20f14b9
commit a1095285e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 11 deletions

View File

@ -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):

View File

@ -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))