# 只使用SQL查询进行重建，是否可能？

**URL:** https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201
**Category:** Support
**Created:** [2015年十二月29日 00:23 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201 "2015-12-29T00:23:00Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2015年十二月29日 00:23 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201/1 "2015-12-29T00:23:00Z")

</div>

So, I have a few SQL queries that “fix” some common issues in posts. Running an SQL query updates the `raw` column only. Now, is there a way to somehow queue those posts for rebaking provided I know their IDs? I mean, maybe there is kind of sidekiq queue where we could put the rebake tasks for the posts?

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2015年十二月29日 20:45 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201/2 "2015-12-29T20:45:15Z")

</div>

While I can’t find the source right now, I think that clearing the cooked version should suffice: One of the regular Sidekiq jobs should then automatically queue a baking task.

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2015年十二月30日 00:38 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201/3 "2015-12-30T00:38:25Z")

</div>

> [@fefrei](#):
>
> clearing the cooked version should suffice: One of the regular Sidekiq jobs should then automatically queue a baking task.

How will displaying the message behave if it needs to be displayed but no cooked version present yet?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2015年十二月30日 00:40 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201/4 "2015-12-30T00:40:11Z")

</div>

This will queue a background full rebake

```plaintext
./launcher enter app
rails c
Post.exec_sql('update posts set baked_version = 0')

```

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2015年十二月30日 00:58 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201/5 "2015-12-30T00:58:32Z")

</div>

Excellent, so I can do the same with an SQL query right from the [data explorer](https://meta.discourse.org/t/32566?silent=true), can I?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2015年十二月30日 04:30 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201/6 "2015-12-30T04:30:04Z")

</div>

No you can not do this from [data explorer](https://meta.discourse.org/t/32566?silent=true) we explicitly disallow write there.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2015年十二月30日 11:06 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201/7 "2015-12-30T11:06:50Z")

</div>

I think it bakes on demand – at least my installation continued looking normally when I did this.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024年六月8日 12:45 UTC](https://meta.discourse.org/t/throw-a-rebake-with-using-an-sql-query-only-is-it-possible/37201/8 "2024-06-08T12:45:59Z")

</div>

此主题已在 3084 天后自动关闭。不再允许回复。
