Preparing an Approval Engine Database

The Approval Engine (AE) application requires a PostgreSQL database for keeping information about:

  • Modules whose objects require approval (for example, Order Management),
  • Actions available for an application,
  • Created workflows,
  • Steps that comprise workflows,
  • Criteria defined in workflows,
  • Incoming requests,
  • And all actions performed on particular approval requests.

Before deploying the database for the Approval Engine application, make sure all prerequisites are met.

To prepare the database for the AE application, complete the following steps:

Prepare a host for the AE database.

  1. Connect to the node where the Approval Engine database will be hosted. Log in to this node as the root user.

  2. Create the create_db.sql script file with the commands required for database creation. To do this, run the following command:

    cat << EOF > /tmp/create_db.sql
     DO
     \$\$
     BEGIN
     	IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'mservice_login') THEN
     	   CREATE ROLE mservice_login LOGIN;
     	   RAISE NOTICE 'Group mservice_login created';
     	END IF;
     END
     \$\$;
     CREATE USER :name PASSWORD :'password';
     \echo User :name created
     GRANT mservice_login to :name;
     \echo User is a member of mservice_login group
     GRANT :name to CURRENT_USER;
     CREATE DATABASE a8n_:name OWNER :name TEMPLATE template0;
     \echo Database a8n_:name created
     REVOKE :name from CURRENT_USER;
     SELECT pg_reload_conf();
     EOF
    
  3. Add the connect permissions for all the mservice_login group members by adding the following lines to the pg_hba.conf configuration file:

    host    all     mservice_login      <ae_app_host_ip>/32       reject
    host all +mservice_login <ae_app_host_ip>/32 md5

    Where:

  4. Create the database by running the following command:

    su - postgres -c "psql -f /tmp/create_db.sql --set ON_ERROR_STOP=on -q -o /dev/null -v name='approvalengineapp' -v password='<db_user_password>'"

    where:

    • <db_user_password> is the password of the AE database user

When installing the component, you will need to specify the connection parameters to this database, which are the following:

Paramater Value
BackNet IP address of the database host The BackNet IP address of the server where the AE database is hosted.
Database name a8n_approvalengineapp
Database user name approvalengineapp
Password of the database user The password you specified during database creation.