User Tools

Site Tools


newdevs:code:add-fields

This is an old revision of the document!


New Developers Working Group

Add Fields to Existing Table

This example came from a need that PINES had for annual reports purposes. It adds two new fields to the Organizational Unit table in order to store federal library codes for each location and make those codes available to the reports engine.

PINES git branch that shows complete files

1. Update the fieldmapper

File location: Open-ILS\examples\fm_IDL.xml

Add the fields in the "class id="aou"" section:

<field name="fscskey" reporter:label="FSCSKEY" reporter:datatype="text"/>
<field name="fscs_seq" reporter:label="FSCS_SEQ" reporter:datatype="text"/>

The field name must match the column name that you add to the database table. The 'reporter:label' text is what will appear in the list when you are building report templates.

2. Update the schema

New installations of Evergreen will use this code when the database tables are created.

File location: Open-ILS\src\sql\Pg\005.schema.actors.sql

Add the fields to the field list in the "CREATE TABLE actor.org_unit" section of SQL:

email TEXT,
phone TEXT,
fscskey TEXT,
fscs_seq TEXT,

opac_visible BOOL

3. Create an upgrade script

Upgrade scripts are required for any changes to the schema or seed data - these are used when a server is being upgraded rather than installed fresh.

File location: Open-ILS\src\sql\Pg\upgrade\XXXX.federal_codes.sql

BEGIN; ALTER TABLE actor.org unit ADD COLUMN fscskey TEXT, ADD COLUMN fscs_seq TEXT; COMMIT;

If you are developing an upgrade script to submit to the Evergreen community, the new upgrade script you create will likely be more complicated. See other examples in the upgrade folder.

newdevs/code/add-fields.1627597613.txt.gz · Last modified: 2022/02/10 13:34 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.