blueprints.guilds: misc fixes to channel creation

Instances should run this SQL to maintain consistency with `schema.sql`
```sql
ALTER TABLE guild_channels DROP CONSTRAINT guild_channels_guild_id_fkey;

ALTER TABLE guild_channels ADD CONSTRAINT guild_id_fkey
FOREIGN KEY (guild_id)
REFERENCES guilds (id)
ON DELETE CASCADE;
```
This commit is contained in:
Luna Mendes 2018-10-26 04:27:48 -03:00
parent d2562d3262
commit 8888534580
1 changed files with 4 additions and 1 deletions

View File

@ -104,7 +104,7 @@ async def _specific_chan_create(channel_id, ctype, **kwargs):
if ctype == ChannelType.GUILD_TEXT:
await app.db.execute("""
INSERT INTO guild_text_channels (id, topic)
VALUES ($1)
VALUES ($1, $2)
""", channel_id, kwargs.get('topic', ''))
elif ctype == ChannelType.GUILD_VOICE:
await app.db.execute(
@ -133,6 +133,9 @@ async def create_guild_channel(guild_id: int, channel_id: int,
WHERE guild_id = $1
""", guild_id)
# account for the first channel in a guild too
max_pos = max_pos or 0
# all channels go to guild_channels
await app.db.execute("""
INSERT INTO guild_channels (id, guild_id, name, position)