From a0129da19843e87ad9186d6316f11d4b38846a6e Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 2 Dec 2018 22:48:01 -0300 Subject: [PATCH 1/3] schema.sql: change roles.color default to 0 fixes the at-everyone role being black. related to !6. - migration.scripts: add 8_roles_default_color --- manage/cmd/migration/scripts/8_roles_default_color.sql | 9 +++++++++ schema.sql | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 manage/cmd/migration/scripts/8_roles_default_color.sql diff --git a/manage/cmd/migration/scripts/8_roles_default_color.sql b/manage/cmd/migration/scripts/8_roles_default_color.sql new file mode 100644 index 0000000..b15fb18 --- /dev/null +++ b/manage/cmd/migration/scripts/8_roles_default_color.sql @@ -0,0 +1,9 @@ +-- update roles.color default to 0 +ALTER TABLE roles + ALTER COLUMN color SET DEFAULT 0; + +-- update all existing guild default roles to +-- color=0 +UPDATE roles + SET color = 0 +WHERE roles.id = roles.guild_id; diff --git a/schema.sql b/schema.sql index b912fe3..bb35d8b 100644 --- a/schema.sql +++ b/schema.sql @@ -519,7 +519,7 @@ CREATE TABLE IF NOT EXISTS roles ( guild_id bigint REFERENCES guilds (id) ON DELETE CASCADE, name text NOT NULL, - color int DEFAULT 1, + color int DEFAULT 0, hoist bool DEFAULT false, position int NOT NULL, permissions int NOT NULL, From a36ea4a11792f5929cc4502b7b96638ddf060ff0 Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 2 Dec 2018 22:49:08 -0300 Subject: [PATCH 2/3] blueprints.guilds: use default value for roles.color --- litecord/blueprints/guilds.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 032d07a..0208bfc 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -133,9 +133,9 @@ async def create_guild(): # is the same as the id of the guild, and create_role # generates a new snowflake. await app.db.execute(""" - INSERT INTO roles (id, guild_id, name, position, permissions, color) - VALUES ($1, $2, $3, $4, $5, $6) - """, guild_id, guild_id, '@everyone', 0, DEFAULT_EVERYONE_PERMS, 0) + INSERT INTO roles (id, guild_id, name, position, permissions) + VALUES ($1, $2, $3, $4, $5) + """, guild_id, guild_id, '@everyone', 0, DEFAULT_EVERYONE_PERMS) # add the @everyone role to the guild creator await app.db.execute(""" From 969b6b80ae62fd7cb341a733c906acf48b128967 Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 2 Dec 2018 22:55:58 -0300 Subject: [PATCH 3/3] schemas: fix regression on REGISTER_WITH_INVITE regression added in https://gitlab.com/luna/litecord/commit/8f2ad0f33d4d031f7030e2ab633d1a5652784354 --- litecord/schemas.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litecord/schemas.py b/litecord/schemas.py index 8518dea..3037d52 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -162,8 +162,9 @@ REGISTER = { 'password': {'type': 'string', 'minlength': 5, 'required': True} } +# only used by us, not discord, hence 'invcode' (to separate from discord) REGISTER_WITH_INVITE = {**REGISTER, **{ - 'invite': {'type': 'string', 'required': True} + 'invcode': {'type': 'string', 'required': True} }}