From a04b3acfaae051b94f2e0b38443ab7a6173cbfff Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 9 Mar 2019 03:27:12 -0300 Subject: [PATCH] storage: add guild.features in get_guild - remove features and guild_features tables --- litecord/storage.py | 5 +--- .../scripts/12_remove_features_table.sql | 4 ++++ schema.sql | 23 ++++--------------- 3 files changed, 10 insertions(+), 22 deletions(-) create mode 100644 manage/cmd/migration/scripts/12_remove_features_table.sql diff --git a/litecord/storage.py b/litecord/storage.py index 1530a65..0c8f6d4 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -155,7 +155,7 @@ class Storage: explicit_content_filter, mfa_level, embed_enabled, embed_channel_id::text, widget_enabled, widget_channel_id::text, - system_channel_id::text + system_channel_id::text, features FROM guilds WHERE guilds.id = $1 """, guild_id) @@ -918,9 +918,6 @@ class Storage: if guild: dinv['guild'] = dict(guild) - - # TODO: query actual guild features - dinv['guild']['features'] = [] else: dinv['guild'] = {} diff --git a/manage/cmd/migration/scripts/12_remove_features_table.sql b/manage/cmd/migration/scripts/12_remove_features_table.sql new file mode 100644 index 0000000..5f37056 --- /dev/null +++ b/manage/cmd/migration/scripts/12_remove_features_table.sql @@ -0,0 +1,4 @@ +DROP TABLE guild_features; +DROP TABLE features; + +ALTER TABLE guilds ADD COLUMN features text[]; diff --git a/schema.sql b/schema.sql index 269ff91..0f5742d 100644 --- a/schema.sql +++ b/schema.sql @@ -362,12 +362,13 @@ CREATE TABLE IF NOT EXISTS guilds ( region text NOT NULL REFERENCES voice_regions (id), - /* default no afk channel - afk channel is voice-only. - */ + features text[], + + -- default no afk channel + -- afk channel is voice-only. afk_channel_id bigint REFERENCES channels (id) DEFAULT NULL, - /* default 5 minutes */ + -- default 5 minutes afk_timeout int DEFAULT 300, -- from 0 to 4 @@ -482,20 +483,6 @@ CREATE TABLE IF NOT EXISTS group_dm_members ( ); - - -CREATE TABLE IF NOT EXISTS features ( - id serial PRIMARY KEY, - feature text NOT NULL -); - -CREATE TABLE IF NOT EXISTS guild_features ( - guild_id bigint REFERENCES guilds (id) ON DELETE CASCADE, - feature integer REFERENCES features (id), - PRIMARY KEY (guild_id, feature) -); - - CREATE TABLE IF NOT EXISTS guild_integrations ( guild_id bigint REFERENCES guilds (id) ON DELETE CASCADE, user_id bigint REFERENCES users (id) ON DELETE CASCADE,