Question about setting SiteSettings in YAML file

AI-generated summary

Question about setting SiteSettings in YAML file

The discussion revolves around setting site settings in a YAML file. maggiomj is currently using around 80 separate statements to set site settings and is looking for a more efficient way to accomplish this.

neounix suggests that most site settings are persisted in the database and therefore don’t need to be set on each rebuild. However, this does not apply to custom site settings that are not persisted in the database. neounix also provides instructions on how to check the site settings in the database.

fzngagan agrees that the lines can be removed, while pfaffman cautions that this approach only makes sense if the goal is to create multiple sites with the same settings that can be easily reset on rebuild. pfaffman asks maggiomj to clarify the problem they are trying to solve by setting site settings in the YAML file.

In my app.yml file, I have many (~80) statements like the below

  - exec: rails r "SiteSetting.some_setting=false"
  - exec: rails r "SiteSetting.some_other_setting=0"
  - exec: rails r "SiteSetting.a_third_setting=0"

This seems dumb (to make each statement separately). Is there a better way to accomplish this? Am I accumulating unnecessary overhead in my rebuild process? Or is this the correct way to do this? Thanks in advance

Hi @maggiomj

If you check the discourse postgresql db, you will see that there is a table for site settings and that most site settings are persisted (saved) in the db.

Since you did not specific the exact site settings you are interested in, it’s hard to make an exact reply; but in general, once these site settings are set up in the db, there is little reason to set them on each rebuild in the yml file.

Of course, this does not apply for any custom site settings which are not persisted in the db.

Hope this helps.

a_server:~# docker exec -it data bash
a_server-data:/# su postgres
postgres@a_server-data:/$ psql discourse
psql (12.2 (Debian 12.2-2.pgdg100+1))
Type "help" for help.

discourse=# \dt *site*
             List of relations
 Schema |     Name      | Type  |   Owner   
--------+---------------+-------+-----------
 public | site_settings | table | discourse
 public | sitemaps      | table | discourse
(2 rows)

discourse=# select count(id) from site_settings;
 count 
-------
   141
(1 row)

discourse=# 

If you compare your site setting directives in your yml file with the db; you can have a pretty good idea of which of your yml site settings directives are redundant.

You can get rid of those lines basically.

It only makes sense to do that if your purpose is to be able to create a bunch of different sites that have those settings, and for those settings to be erased on the next rebuild if someone changes them in the UX.

What problem are you trying to solve by setting those in your yml file?