# Unlist a topic using rails console

**URL:** https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189
**Category:** Support
**Tags:** unlisting
**Created:** [January 23, 2017, 5:16am UTC](https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189 "2017-01-23T05:16:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![shahidh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shahidh/32/121310_2.png) [@shahidh](https://meta.discourse.org/u/shahidh)
#### Post date: [January 23, 2017, 5:16am UTC](https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189/1 "2017-01-23T05:16:21Z")

</div>

We have a use case where we need to close all existing topics and unlist them. I have closed all topics using the rails console by executing

```plaintext
Topic.where(closed: false).find_each do |topic| 
  topic.update_status("closed", true, Discourse.system_user)
end

```

But, when I try to do the same to unlist topics by executing

```plaintext
topic.update_status("unlisted", true, Discourse.system_user)

```

I get this error:

```plaintext
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "unlisted" of relation "topics" does not exist
LINE 1: UPDATE "topics" SET "unlisted" = 't' WHERE "topics"."id" = 1

```

From which I understand that there is no `unlisted` column for the topic object.

How can I unlist a topic using console?

---

<div class="post-metadata">

### Author: ![traceymoko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/traceymoko/32/483235_2.png) [@traceymoko](https://meta.discourse.org/u/traceymoko)
#### Post date: [January 23, 2017, 5:25am UTC](https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189/2 "2017-01-23T05:25:48Z")

</div>

I don’t have much idea 😁 and shouldn’t say anything, but what came to me was maybe try `"listed"` column and set to `false`? at least something to try until someone else sees 😁 (or I find something while peeking around)

Edit: I think I can see things like `closed`, `visible`, `enabled`, `archived`, `disabled` and `autoclosed` in [/apps/models/topic\_status\_update.rb](https://github.com/discourse/discourse/blob/master/app/models/topic_status_update.rb) but again, I have no idea 🙂

---

<div class="post-metadata">

### Author: ![shahidh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shahidh/32/121310_2.png) [@shahidh](https://meta.discourse.org/u/shahidh)
#### Post date: [January 23, 2017, 5:33am UTC](https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189/3 "2017-01-23T05:33:11Z")

</div>

I tried the `listed` column. That one also does not exist. I am trying to get a peek into the table using `phppgadmin` now

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [January 23, 2017, 5:37am UTC](https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189/4 "2017-01-23T05:37:46Z")

</div>

I believe you are looking for “visible”.

But don’t let me stop you from learning about the database before you start running queries against it.

_Please_ save a backup just in case you need it later.

---

<div class="post-metadata">

### Author: ![traceymoko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/traceymoko/32/483235_2.png) [@traceymoko](https://meta.discourse.org/u/traceymoko)
#### Post date: [January 23, 2017, 5:45am UTC](https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189/5 "2017-01-23T05:45:42Z")

</div>

> [@shahidh](#):
>
> I am trying to get a peek into the table

a great idea 😃

---

<div class="post-metadata">

### Author: ![shahidh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shahidh/32/121310_2.png) [@shahidh](https://meta.discourse.org/u/shahidh)
#### Post date: [January 23, 2017, 6:39am UTC](https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189/6 "2017-01-23T06:39:17Z")

</div>

`visible` it is.

```plaintext
topic.update_status("visible", false, Discourse.system_user)

```

Thanks guys

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [January 23, 2017, 10:22am UTC](https://meta.discourse.org/t/unlist-a-topic-using-rails-console/56189/7 "2017-01-23T10:22:37Z")

</div>


