mirror of https://gitlab.com/litecord/litecord.git
guilds: properly delete child channels on guild delete
This commit is contained in:
parent
1d36038469
commit
7e79abf344
|
|
@ -232,6 +232,22 @@ async def _del_from_table(table: str, user_id: int):
|
||||||
async def delete_guild(guild_id: int):
|
async def delete_guild(guild_id: int):
|
||||||
"""Delete a single guild."""
|
"""Delete a single guild."""
|
||||||
await _del_from_table("vanity_invites", guild_id)
|
await _del_from_table("vanity_invites", guild_id)
|
||||||
|
|
||||||
|
# while most guild channel tables have 'ON DELETE CASCADE', this
|
||||||
|
# must not be true to the channels table, which is generic for any channel.
|
||||||
|
#
|
||||||
|
# the drawback is that this causes breakdown on the data's semantics as
|
||||||
|
# we get a channel with a type of GUILD_TEXT/GUILD_VOICE but without any
|
||||||
|
# entry on the guild_channels table, causing errors.
|
||||||
|
for channel_id in await app.storage.get_channel_ids(guild_id):
|
||||||
|
await app.db.execute(
|
||||||
|
"""
|
||||||
|
DELETE FROM channels
|
||||||
|
WHERE channels.id = $1
|
||||||
|
""",
|
||||||
|
channel_id,
|
||||||
|
)
|
||||||
|
|
||||||
await app.db.execute(
|
await app.db.execute(
|
||||||
"""
|
"""
|
||||||
DELETE FROM guilds
|
DELETE FROM guilds
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue