Draft: Store new application settings using rails-settings-cached gem
What does this MR do and why?
Store new application settings using rails-settings-cached gem https://github.com/huacnlee/rails-settings-cached.
This gem stores the application settings in rows instead of columns as
we do in the application_settings
table. The gem also uses Rails.cache
to cache the results and invalidates the cache whenever any record is
updated.
It addresses almost all of the problems we have with the current
implementation of the application_settings
and retains its advantages:
11
- Limited column size: Postgres limits the column count to 1600 and currently in production we have around 600 columns. Sooner or later we'll run out of this limit. The gem stores the data in rows instead of columns.
- Adding a new setting requires DB review: Currently, we add a new column to store the new setting. To store a new setting in this gem we just need to add a field to the model with a default and its type.
- Supports different data types like we currently do.
- Supports rails validations like we currently do.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Here's the syntax to use the new gem https://github.com/huacnlee/rails-settings-cached?tab=readme-ov-file#usage.
Assigning a value to the field automatically validates and saves it.