User Tools

Site Tools


newdevs:code:add-fields

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
newdevs:code:add-fields [2021/07/29 18:19] – [2. Update the schema] tmccannanewdevs:code:add-fields [2024/03/28 22:15] (current) – [3. Edit seed data and create an upgrade script] sandbergja
Line 4: Line 4:
 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.  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. 
  
-[[https://git.evergreen-ils.org/?p=evergreen/pines.git;a=commit;h=701177c67fa6bde4ce19a31d30e3d896eb134a7a| PINES Git Branch]]+[[https://git.evergreen-ils.org/?p=evergreen/pines.git;a=commit;h=701177c67fa6bde4ce19a31d30e3d896eb134a7a| PINES git branch that shows complete files]]
  
 ===== 1. Update the fieldmapper ===== ===== 1. Update the fieldmapper =====
Line 12: Line 12:
 Add the fields in the "class id="aou"" section:  Add the fields in the "class id="aou"" section: 
  
-''<nowiki><field name="fscskey" reporter:label="FSCSKEY" reporter:datatype="text"/></nowiki>''\\ +''<field reporter:label="Hours of Operation" name="hours_of_operation" oils_persist:virtual="true" reporter:datatype="link"/>''\\ 
-''<nowiki><field name="fscs_seq" reporter:label="FSCS_SEQ" reporter:datatype="text"/></nowiki>''+**''<field name="fscskey" reporter:label="FSCSKEY" reporter:datatype="text"/>''**\\ 
 +**''<field name="fscs_seq" reporter:label="FSCS_SEQ" reporter:datatype="text"/>''**\\ 
 +''</fields>''
  
 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.  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 ===== ===== 2. Update the schema =====
 +
 +New installations of Evergreen will use the code in the Pg folder when the database tables are created. If you are creating a new table for a brand new feature, you'll most likely need to create a new schema file, but in this case we are updating an existing table in the actor schema.
  
 File location: Open-ILS\src\sql\Pg\005.schema.actors.sql File location: Open-ILS\src\sql\Pg\005.schema.actors.sql
Line 26: Line 30:
 ''phone TEXT,''\\ ''phone TEXT,''\\
 **''fscskey TEXT,''\\ **''fscskey TEXT,''\\
-''fscs_seq TEXT,''\\**+''fscs_seq TEXT,''**\\
 ''opac_visible BOOL'' ''opac_visible BOOL''
  
  
 +===== 3. Edit seed data and create an upgrade script =====
 +
 +Updates to the seed data files as well as upgrade scripts are required for any changes to the schema or seed data. (The seed data files are used for fresh installs and the upgrade scripts are used by existing installations that are upgrading.)
 +
 +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. The "XXXX" in the file name is a placeholder - when the core committers add it to man, they will assign it a number. 
  
 +For more information on upgrade scripts, see [[newdevs:db:upgrade_scripts|Database upgrade scripts]]
  
  
newdevs/code/add-fields.1627597149.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.