Repository: Cog-Creators/Red-DiscordBot

Issue:
[V3 Config postgres] No cogs configs converted
# Other bugs

#### What were you trying to do?

Convert from JSON config driver to postgres (`redbot-setup convert %instance% postgres`)

#### What were you expecting to happen?

Transfer everything from JSON to postgres DB

#### What actually happened?

Core config is converted, cogs config not converted, creating ID-configs in progress

#### How can we reproduce this issue?

1. Setup/have bot with cogs configs in JSON
2. Shutdown bot and try to convert to postgres
	* Check `%datapath%/cogs` - there will be folders with configs id's with empty configs (every `config.json` in this folders contains `{}`)
	![JSON configs](https://moeka.is-a-good-waifu.com/BPs4zDZ.png)
	* Check database - there is no cogs configs
	![database](https://moeka.is-a-good-waifu.com/2LqbbbG.png)
3. Startup bot
4. Check configuration of cogs
	* It will be default, as cogs just were installed



Discussion:

Resolving patch:
diff --git a/redbot/core/drivers/json.py b/redbot/core/drivers/json.py
--- a/redbot/core/drivers/json.py
+++ b/redbot/core/drivers/json.py
@@ -181,11 +181,11 @@ async def aiter_cogs(cls) -> AsyncIterator[Tuple[str, str]]:
                     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):
diff --git a/redbot/setup.py b/redbot/setup.py
--- a/redbot/setup.py
+++ b/redbot/setup.py
@@ -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))
 


Test patch: