With the ability (coming soon) to make new topics wikis by default, it will likely be met with a desire to convert the existing topics in that category to wikis as well. Here’s the process:
-
Make sure you have a backup in place.
You can do this via the UI. This is just in case something goes wrong.
-
Get the
id
of the category you want to edit../launcher enter app rails c % Category.find_by(name: "Wiki Topics Category").id => 12
-
You’ll need to run SQL to update the first post of each topic in that category. This is the SQL query:
UPDATE posts SET wiki=true WHERE id IN ( SELECT p.id FROM posts p LEFT JOIN topics t ON p.topic_id = t.id WHERE p.post_number = 1 AND t.category_id = YOUR_CATEGORY_ID);
For example, if my category id is 12, then this is the command I need to run:
./launcher enter app rails c % User.exec_sql("UPDATE posts SET wiki=true WHERE id IN (SELECT p.id FROM posts p LEFT JOIN topics t ON p.topic_id = t.id WHERE p.post_number = 1 AND t.category_id = 12);")