/
/
/
Storing any data in the panel database

Storing any data in the panel database

Sometimes, when writing plugins, you need to store additional parameters for built-in objects. For all tables managed by ispmanager, you can add additional fields to the database tables without changing the application code. The added fields will be processed using standard algorithms: the presence of the field in the table and its type will be monitored (if necessary, the field will be added or its type will be changed). The values ​​of such fields can be changed through the edit form or displayed in the list of records (simply adding the corresponding field to the metadata).

In order to add an additional field to a table, create the directory /usr/local/mgr5/etc/sql/ispmgr.{table_name}.addon or //usr/local/mgr5/etc/sql/{table_name}.addon

Each file in either of these directories describes a different field in the table. The field name matches the file name. By default, a string type field with the maximum possible length (VARCHAR(255)) will be created, but you can specify a different data type, as well as define a default value and access parameters. File example:

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

type defines the type of the field. Possible values:

  • string — the size parameter specifies the maximum cell length; 255 by default.
  • int — integer field
  • bool — Boolean value (on/off)
  • decimal — field for storing fixed-point numbers
  • date — field for storing dates
  • money — field for storing fixed-point numbers
  • text — text field
  • idn — field for storing internationalized domain names (IDNs)
  • long — extended integer field
  • datetime — field for storing a time and a date

access_read restricts read access to the field value based on user access levels. By default, the field is accessible to all users.

access_write sets write access (similar to access_read)

access sets read and write access and overrides settings set by access_read and access_write.

For more information about access levels, see the article Access levels.

default — sets the default value. To set the value to NULL, specify the parameter as follows:

default=null

After that, clear the cache and restart the panel:

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