When customizing it may be necessary to store additional information in an existing table. You could just add columns to that table and use them in your scripts, and that would be enough, but you won't be able to use those columns through db_form class. Further, some tables, like the person table have a special configuration in the administration, and the new columns won't appear.
I explain the process of adding a column through an example: I want to add a column "eyes" to the person table to store the color of the eyes of a person.
I add the column to the person table.
ALTER TABLE sl_person ADD eyes VARCHAR(32) NOT NULL;
I then add the column description to the tabledesc table. The column type is one of the supported Metabase column types.
INSERT INTO sl_tabledesc (id_tabledesc, tablename, field, type, length, is_primary) VALUES (100001, 'person', 'eyes', 'text', 32, 'N');
The third and last step is to add rows in slotfield table. This is needed only for the person table at the moment, and can be done through the slot administration.
![]() | Choose a high Id for local records |
|---|---|
You have to choose a high Id, because every upgrade will delete and re-insert tabledesc and slotfields rows, with lower Ids, but will preserve those with higher ones. Even Reset table with default data will preserve local data following this rule, even if reloading a table, provided that an Id over 100.000 is used. | |