From 04503aff17d9d41b4c19df1c7e5f78720e8cfe98 Mon Sep 17 00:00:00 2001 From: Alec LaLonde Date: Fri, 12 Mar 2021 22:54:15 -0700 Subject: [PATCH] Added migration for metafam rank discord role IDs --- .../down.sql | 3 + .../up.sql | 3 + .../backend/src/handlers/graphql/queries.ts | 2 +- packages/web/graphql/fragments.ts | 2 +- schema.graphql | 132 ++++++++++++++++-- 5 files changed, 125 insertions(+), 17 deletions(-) create mode 100644 hasura/migrations/1615614610171_add_metafam_rank_role_ids/down.sql create mode 100644 hasura/migrations/1615614610171_add_metafam_rank_role_ids/up.sql diff --git a/hasura/migrations/1615614610171_add_metafam_rank_role_ids/down.sql b/hasura/migrations/1615614610171_add_metafam_rank_role_ids/down.sql new file mode 100644 index 00000000..d2c6ea34 --- /dev/null +++ b/hasura/migrations/1615614610171_add_metafam_rank_role_ids/down.sql @@ -0,0 +1,3 @@ +UPDATE guild +SET discord_metadata = discord_metadata - 'rankRoleIds' +WHERE guild.guildname = 'metafam'; diff --git a/hasura/migrations/1615614610171_add_metafam_rank_role_ids/up.sql b/hasura/migrations/1615614610171_add_metafam_rank_role_ids/up.sql new file mode 100644 index 00000000..89c40a6e --- /dev/null +++ b/hasura/migrations/1615614610171_add_metafam_rank_role_ids/up.sql @@ -0,0 +1,3 @@ +UPDATE guild +SET discord_metadata = jsonb_set(discord_metadata, '{rankRoleIds}', '{"DIAMOND": "659518696506785802", "PLATINUM": "659519668553252864", "GOLD": "659519940159602746", "SILVER": "665574957094535199", "BRONZE": "675569758682480661"}') +WHERE guild.guildname = 'metafam'; diff --git a/packages/backend/src/handlers/graphql/queries.ts b/packages/backend/src/handlers/graphql/queries.ts index 052a812e..b56e4dfc 100644 --- a/packages/backend/src/handlers/graphql/queries.ts +++ b/packages/backend/src/handlers/graphql/queries.ts @@ -83,13 +83,13 @@ export const GuildFragment = gql` id guildname description - discord_invite_url join_button_url logo moloch_address name type website_url + discord_metadata guild_accounts { type identifier diff --git a/packages/web/graphql/fragments.ts b/packages/web/graphql/fragments.ts index c074516f..91e472ef 100644 --- a/packages/web/graphql/fragments.ts +++ b/packages/web/graphql/fragments.ts @@ -66,7 +66,7 @@ export const GuildFragment = gql` id guildname description - discord_invite_url + discord_metadata join_button_url logo moloch_address diff --git a/schema.graphql b/schema.graphql index 2c87e563..6e651864 100644 --- a/schema.graphql +++ b/schema.graphql @@ -451,7 +451,10 @@ type guild { GuildType: GuildType! description: String discord_id: String - discord_invite_url: String + discord_metadata( + """JSON select path""" + path: String + ): jsonb """An array relationship""" guild_accounts( @@ -797,6 +800,11 @@ input guild_aggregate_order_by { min: guild_min_order_by } +"""append existing jsonb value of filtered columns with new jsonb value""" +input guild_append_input { + discord_metadata: jsonb +} + """ input type for inserting array relation for remote table "guild" """ @@ -815,7 +823,7 @@ input guild_bool_exp { _or: [guild_bool_exp] description: String_comparison_exp discord_id: String_comparison_exp - discord_invite_url: String_comparison_exp + discord_metadata: jsonb_comparison_exp guild_accounts: guild_account_bool_exp guild_players: guild_player_bool_exp guildname: String_comparison_exp @@ -844,6 +852,28 @@ enum guild_constraint { guild_discord_id_key } +""" +delete the field or element with specified path (for JSON arrays, negative integers count from the end) +""" +input guild_delete_at_path_input { + discord_metadata: [String] +} + +""" +delete the array element with specified index (negative integers count from the +end). throws an error if top level container is not an array +""" +input guild_delete_elem_input { + discord_metadata: Int +} + +""" +delete key/value pair or string element. key/value pairs are matched based on their key value +""" +input guild_delete_key_input { + discord_metadata: String +} + """ input type for inserting data into table "guild" """ @@ -851,7 +881,7 @@ input guild_insert_input { GuildType: GuildType_obj_rel_insert_input description: String discord_id: String - discord_invite_url: String + discord_metadata: jsonb guild_accounts: guild_account_arr_rel_insert_input guild_players: guild_player_arr_rel_insert_input guildname: String @@ -870,11 +900,6 @@ input guild_insert_input { type guild_max_fields { description: String discord_id: String - discord_invite_url: String - guildname: String - id: uuid - join_button_url: String - logo: String moloch_address: String name: String website_url: String @@ -886,7 +911,6 @@ order by max() on columns of table "guild" input guild_max_order_by { description: order_by discord_id: order_by - discord_invite_url: order_by guildname: order_by id: order_by join_button_url: order_by @@ -900,7 +924,6 @@ input guild_max_order_by { type guild_min_fields { description: String discord_id: String - discord_invite_url: String guildname: String id: uuid join_button_url: String @@ -916,7 +939,6 @@ order by min() on columns of table "guild" input guild_min_order_by { description: order_by discord_id: order_by - discord_invite_url: order_by guildname: order_by id: order_by join_button_url: order_by @@ -961,7 +983,7 @@ input guild_order_by { GuildType: GuildType_order_by description: order_by discord_id: order_by - discord_invite_url: order_by + discord_metadata: order_by guild_accounts_aggregate: guild_account_aggregate_order_by guild_players_aggregate: guild_player_aggregate_order_by guildname: order_by @@ -1165,6 +1187,11 @@ enum guild_player_update_column { player_id } +"""prepend existing jsonb value of filtered columns with new jsonb value""" +input guild_prepend_input { + discord_metadata: jsonb +} + """ select columns of table "guild" """ @@ -1176,7 +1203,7 @@ enum guild_select_column { discord_id """column name""" - discord_invite_url + discord_metadata """column name""" guildname @@ -1212,7 +1239,7 @@ input type for updating data in table "guild" input guild_set_input { description: String discord_id: String - discord_invite_url: String + discord_metadata: jsonb guildname: String id: uuid join_button_url: String @@ -1235,7 +1262,7 @@ enum guild_update_column { discord_id """column name""" - discord_invite_url + discord_metadata """column name""" guildname @@ -1681,6 +1708,37 @@ input json_comparison_exp { _nin: [json!] } +scalar jsonb + +""" +expression to compare columns of type jsonb. All fields are combined with logical 'AND'. +""" +input jsonb_comparison_exp { + """is the column contained in the given json value""" + _contained_in: jsonb + + """does the column contain the given json value at the top level""" + _contains: jsonb + _eq: jsonb + _gt: jsonb + _gte: jsonb + + """does the string exist as a top-level key in the column""" + _has_key: String + + """do all of these strings exist as top-level keys in the column""" + _has_keys_all: [String!] + + """do any of these strings exist as top-level keys in the column""" + _has_keys_any: [String!] + _in: [jsonb!] + _is_null: Boolean + _lt: jsonb + _lte: jsonb + _neq: jsonb + _nin: [jsonb!] +} + """ columns and relationships of "me" """ @@ -2779,6 +2837,28 @@ type mutation_root { update data of the table: "guild" """ update_guild( + """append existing jsonb value of filtered columns with new jsonb value""" + _append: guild_append_input + + """ + delete the field or element with specified path (for JSON arrays, negative integers count from the end) + """ + _delete_at_path: guild_delete_at_path_input + + """ + delete the array element with specified index (negative integers count from + the end). throws an error if top level container is not an array + """ + _delete_elem: guild_delete_elem_input + + """ + delete key/value pair or string element. key/value pairs are matched based on their key value + """ + _delete_key: guild_delete_key_input + + """prepend existing jsonb value of filtered columns with new jsonb value""" + _prepend: guild_prepend_input + """sets the columns of the filtered rows to the given values""" _set: guild_set_input @@ -2810,6 +2890,28 @@ type mutation_root { update single row of the table: "guild" """ update_guild_by_pk( + """append existing jsonb value of filtered columns with new jsonb value""" + _append: guild_append_input + + """ + delete the field or element with specified path (for JSON arrays, negative integers count from the end) + """ + _delete_at_path: guild_delete_at_path_input + + """ + delete the array element with specified index (negative integers count from + the end). throws an error if top level container is not an array + """ + _delete_elem: guild_delete_elem_input + + """ + delete key/value pair or string element. key/value pairs are matched based on their key value + """ + _delete_key: guild_delete_key_input + + """prepend existing jsonb value of filtered columns with new jsonb value""" + _prepend: guild_prepend_input + """sets the columns of the filtered rows to the given values""" _set: guild_set_input pk_columns: guild_pk_columns_input!