How do you store site-wide settings in the database?

I’m starting to implement some simple site-wide settings and I’m curious how others have done this. I have an admin section for managing users, products, etc which is for me and the founder (not any users). I want to have the ability in this admin section to, for example, turn on maintenance mode.

I’m considering a couple different DB architectures for this. Each of them uses a table called Site Settings.

  1. Each setting is stored in a different row in the Site Settings table.
    Create an option set called “Settings” that contains a list of settings, like Maintenance Mode.
    In the Site Settings DB table, have fields for Setting, which takes an Option set Settings, and other fields for yes/no, text, number, and potentially others that could be relevant to a setting.

  2. The Site Settings table has one row, and has a field for each setting with the appropriate data type. No need for Option sets.

Any opinions on these? They both seem viable to me and I don’t think there are any deal-breaking cons for either, but is there a better way?

Thanks for you thoughts!

I just have a global settings data type with 1 row storing my global settings.

Just be mindful to not bloat it with things like multiple lists of things in fields that you expect to grow over time or store sensitive data.

1 Like

I use option 2!

1 Like

That’s what I was leaning towards, thanks for sharing.