The recommended way to add new tables or fields to the ProcessMaker database(s) is to create a plugin and then edit the
schema.xml file in your plugin source code to add the desired tables and fields. See
Plugin Development:Altering the Database Structure.
However, creating a plugin is complicated and it doesn't work in Windows due to the lack of symbolic links. Another way to alter the database structure is to edit the
processmaker/workflow/engine/config/schema.xml file with a plain text editor to add the desired tables and fields. For example, the following code at the end of the file before the </database> tag adds a new table to the
wf_workspace database, which is named
MY_MESSAGES:
Code: Select all <table name="MY_MESSAGES" idMethod="native">
<column name="ID" type="INTEGER" size="8" auto_increment="true" primaryKey="true"/>
<column name="FIRST_NAME" type="VARCHAR" size="50" required="false"/>
<column name="LAST_NAME" type="VARCHAR" size="50" required="true" />
<column name="MSG" type="LONGVARCHAR" required="false"/>
<column name="SUBJECT" type="VARCHAR" size="200" required="true" />
<column name="STATUS" type="VARCHAR" size="30" required="true" />
<column name="SEND_DATE" type="TIMESTAMP" required="true" />
<column name="CASE_ID" type="VARCHAR" size="32" required="true" default="" />
<column name="DEL_INDEX" type="INTEGER" required="true" default="0"/>
<index name="indexLastName">
<index-column name="LAST_NAME"/>
</index>
</table>
</database>
To apply your changes to the database, open a terminal (command line prompt) and change to the directory where the ProcessMaker code is installed. Then, issue the
php processmaker database-upgrade command to apply the changes in the schema to the database:
Code: Select allcd /opt/processmaker
php processmaker database-upgrade
[color=#008000]Note:[/color] In Linux, run these commands as the root user or prepend <b>sudo</b> to each command.
[color=#008000]Note:[/color] if using Windows, it is necessary to specify the full path to the [b]php.exe[/b] file when executing PHP.
The above example will apply the database changes to all available workspaces. If only need to insert the changes to one workspace, then specify the workspace with the [b]-w[/b] option.
The output of the [b]processmaker database-upgrade[/b] command, should be similar to the following if there are no errors in the [b]schema.xml[/b] file:
[code]Upgrading database in workflow
-> 1 tables to add
-> Nothing to change in the data base structure of RBAC
-> Row updated in DASHLET
-> Row updated in DASHLET
-> Row updated in DASHLET
-> Row updated in DASHLET
-> Verifying roles permissions in RBAC
All roles permissions already updated
-> Migrating the Intermediate Email Event
Migrating Itee Done
0 records where patched to use SELF_SERVICE feature.
-> Schema fixed
If wishing to run this command in the future, remember that these changes in the
schema.xml file need to be reapplied after upgrading ProcessMaker, since they will be overwritten by each upgrade. If wishing to avoid this problem, then create a plugin instead.