COREmanager Documentation

How to add additional table fields

 

Sometimes you may need to save additional parameters of objects when writing a custom plug-un. With COREmanager (Class mgr db::Cache) you can add additional fields into the database table without modifying the application code. The fields that you add will be processed by standard algorithms: a field will be checked in the table (it will be added or modified, if needed), its values can be modified in the edit form or they can be displayed in the list (you will only need to add the corresponding field into metadata).

To add an additional field to the table, you should create catalog etc/sql/{product_name}.{table_name}.addon or etc/sql/{table_name}.addon

To add an additional field, create the etc/sql/{product_name}.{table_name}.addon or etc/sql/{table_name}.addon directories. Every file in these directories describes a separate table field. The field name matches the file name. By default, the string field will be created. Its maximum length is (VARCHAR(255)). You can set another data type, default value, or access permissions (Struct mgr_db::TableDesc::Field). Example of a file:

type=string
size=40
access_read= registered
access_write=admin+
default=0.0.0.0


type - defines a field type. Possible values are names of inheritor classes Class mgr db::Field. Example: the string name defines a field type class mgr_db::StringField. int - class mgr_db::IntFieldsizefield

size  - (for class mgr_db::StringField). The default value: 255

access_read - restrict read access for different user roles (See Namespace mgr access). By default, this field is available to all users.

access_write - write access (analogous to access_read)

access - sets read and write access, and overwrites the configuration set through (access_read and access_write)

default - sets the default value

default null

Clear cash and restart the panel:

rm -rf /usr/local/mgr5/var/.db.cache
killall core