# Locked query field for system badges

**URL:** https://meta.discourse.org/t/locked-query-field-for-system-badges/83415
**Category:** Support
**Tags:** badges
**Created:** [March 20, 2018, 4:44pm UTC](https://meta.discourse.org/t/locked-query-field-for-system-badges/83415 "2018-03-20T16:44:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![iidbae](https://avatars.discourse-cdn.com/v4/letter/i/a183cd/32.png) [@iidbae](https://meta.discourse.org/u/iidbae)
#### Post date: [March 20, 2018, 4:44pm UTC](https://meta.discourse.org/t/locked-query-field-for-system-badges/83415/1 "2018-03-20T16:44:25Z")

</div>

This is my first topic after become a member here since 222 days ago.

1. How to copy-paste this code?  

2. I want to give a badge for 25 successful invitations. So, I only need change the value` HAVING COUNT (*) >= 5` into `HAVING COUNT (*) >= 25`, and give a Gold badge type too. Am I right?

I found similar topic ["Promoter" Badge broken?](https://meta.discourse.org/t/promoter-badge-broken/34413) but I just want to confirm, because I am not a really understand in coding.

Sorry for my stupid question.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [March 20, 2018, 4:50pm UTC](https://meta.discourse.org/t/locked-query-field-for-system-badges/83415/2 "2018-03-20T16:50:41Z")

</div>

Here are the steps for enabling the SQL Badge Queries

> [@Enable Badge SQL](https://meta.discourse.org/t/badge-sql-can-no-longer-be-edited-by-default/47894):
>
> bookmark This guide explains how to enable Badge SQL in Discourse and discusses the associated security and performance risks. person_raising_hand Required user level: Administrator warning Enabling Badge SQL can pose security and performance risks. To maintain security and performance integrity, as of Discourse 1.6, the ability for administrators to edit badge SQL directly is disabled by default. The two primary concerns around enabling Badge SQL are: Security: Allowing direct SQL …

---

<div class="post-metadata">

### Author: ![iidbae](https://avatars.discourse-cdn.com/v4/letter/i/a183cd/32.png) [@iidbae](https://meta.discourse.org/u/iidbae)
#### Post date: [March 20, 2018, 4:56pm UTC](https://meta.discourse.org/t/locked-query-field-for-system-badges/83415/3 "2018-03-20T16:56:57Z")

</div>

Thank you Cpradio, yes I have enabled the SQL ~~within 3 days~~ , but its still locked.  
I believe its for security purpose.  
I tried to explore the Github too, but still does not know how to find the code line.

---

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [March 20, 2018, 5:22pm UTC](https://meta.discourse.org/t/locked-query-field-for-system-badges/83415/4 "2018-03-20T17:22:11Z")

</div>

You can find the badge query SQL here: [discourse/lib/badge\_queries.rb at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/lib/badge_queries.rb)

---

<div class="post-metadata">

### Author: ![iidbae](https://avatars.discourse-cdn.com/v4/letter/i/a183cd/32.png) [@iidbae](https://meta.discourse.org/u/iidbae)
#### Post date: [March 21, 2018, 2:53am UTC](https://meta.discourse.org/t/locked-query-field-for-system-badges/83415/5 "2018-03-21T02:53:32Z")

</div>

Thank you very much Simon.  
I put wrong keyword in searching the code in the repository.  
After I found the sql query, I still confuse.

I want to open another support topic, to make another question relating to this.  
Thank you.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [March 26, 2018, 10:00pm UTC](https://meta.discourse.org/t/locked-query-field-for-system-badges/83415/6 "2018-03-26T22:00:08Z")

</div>

This topic was automatically closed after 33 hours. New replies are no longer allowed.
