Table of Contents
New Developers Working Group
Adding a Library Setting
These instructions cover how to add a library setting to the database. The example is for adding a library setting that can be reference by the Hemlock app. Setting types are in config.org_unit_setting_type.
- Add instructions about how to reference the setting in other places in the code.
- Add instructions on writing seed data for contributing back to the community.
1. Determine the setting group and add one if necessary
Setting groups are listed in the table config.settings_group. If none of the listed groups are appropriate, you can add one to the table like so:
INSERT INTO config.settings_group (name, label) VALUES ('hemlock', 'Hemlock App');
2. Determine if you need to add an fm_class
If you are referencing something that exists in another table, you may need this. Most library settings don't have one. This is not necessary for our example.
Run the following for a list of settings where fm_class is used:
SELECT * FROM config.org_unit_setting_type WHERE fm_class IS NOT NULL;
3. Determine the datatype for the value
Currently used datatypes are:
You can look at examples similar to the setting you want to add to determine the datatype. For our example, the most other settings pointing to external URLs use the string datatype, so this is what we will use.
4. Add a reference to VIEW or UPDATE permissions if necessary
If there are permissions related to your setting, you can point to them in the view_perm and update_perm columns. There are no related permissions for our example.
5. Add the setting type to the table
Once you determine what fields need to be referenced, you can add your new setting type to the table.
INSERT INTO config.org_unit_setting_type (name, label, grp, description, datatype) VALUES ('hemlock.events_calendar_url', 'Events calendar URL to display in the Hemlock app', 'hemlock', 'Direct link to library's events calendar for display in the Hemlock app.', 'string');
You should now be able to add a new library setting via the GUI or via the actor.org_unit_setting table.