Loading the HCL Commerce+ database schema

Loading the HCL Commerce+ database schema is a important step in setting up the Commerce+ environment. This process involves creating the required database schema, loading bootstrap data, and configuring default users. A script (initdb_db2_sample.sh) is provided to automate these tasks.

Before you begin

Before proceeding, ensure the following:

  1. Installing and configuring an IBM Db2 database.
  2. You have created an administrative database user (by default, named wcs). This user will be used by HCL Commerce+ to connect to the database.
  3. Ensure that you have access to a running Utility server Docker container. This container is required to obtain the needed scripts.
.

About this task

The database schema is the foundation of the Commerce+environment. It includes tables, views, stored procedures, and other database objects required for the application to function. Additionally, the schema loading process creates two essential users:
wcsadmin
The site administrator account used to manage the Commerce+ environment.
spiuser
The internal user with the role "RemoteConfigurationReaders". This user is used for inter-component server API invocation only. The spiuser user is configured in the Store server, Search server and Customization (xC) server, and is used in the API invocation from those servers to the Transaction server. This user cannot be disabled. In the event that this user is disabled, the necessary component servers cannot connect to the Transaction server.
The script also allows you to load sample data for testing and validation purposes, which is particularly useful for verifying the setup and setup test environments.
Important:
Sample Data
Loading sample data (sampleData) is recommended for testing and validation. For production environments, use noSample and populate the database with your own data.
Security
Always use custom values for the merchantKey, wcsadminPassword, and spiuserPassword. Do not use default values provided in examples.
SSL Configuration
By default SSL is enabled on the database server, provide the SSL key file and password when running the script.

Procedure

  1. Copy the initdb_db2_sample.sh script from the Utility server Docker container to the machine running the IBM Db2 server.
    bash 
    docker cp container_name:/opt/CommerceUtilities/bin/initdb_db2_sample.sh /path/to/destination/ 
    Replace container_name with the name of your Utility server container.
    Ensure the script has execute permissions:
    bash chmod +x /path/to/destination/initdb_db2_sample.sh
  2. Execute the script with the required parameters to create the database schema and load data. The command syntax is as follows:
    bash 
    
    ./initdb_db2_sample.sh type dbName dbServer dbPort dbaUser dbaPassword dbUser dbPassword merchantKey wcsadminSalt 
    wcsadminPassword spiuserSalt spiuserPassword withSample [sslKeyFile sslKeyPassword] 
    Where:
    Parameter Description
    type The type of environment. Valid values: staging (enables workspaces) or production.
    dbName The name of the database (e.g., mall).
    dbServer The hostname of the database server.
    dbPort The port number of the database server (default: 50000).
    dbaUser The database administrator username.
    dbaPassword The database administrator password.
    dbUser The database username (e.g., wcs).
    dbPassword The database user password.
    merchantKey A 32-character hexadecimal key used for encryption. Example: 1a1a1a1a1a1a1a1a2b2b2b2b2b2b2b2b.
    wcsadminSalt A random string used to encrypt the wcsadminPassword.
    wcsadminPassword The password for the wcsadmin user.
    spiuserSalt A random string used to encrypt the spiuserPassword.
    spiuserPassword The password for the spiuser user.
    withSample Determines whether to load sample data. Valid values: sampleData or noSample.
    sslKeyFile (Optional) Path to the SSL key file if SSL is enabled on the database server.
    sslKeyPassword (Optional) Password for the SSL key file.
    bash 
    
    ./initdb_db2_sample.sh staging mall mydb.hcl.com 50000 db2inst1 myunguessablepassword wcs wcs1 
    1a1a1a1a1a1a1a1a2b2b2b2b2b2b2b2b 3h8x876vd8g3 wcs1admin 7j2lhm2vjpoc QxV7uCk6RRiwvPVaa4wdD78jaHi2za8ssjneNMdu3vgqi 
    sampleData /opt/java/openjdk/lib/security/cacerts changeit 
  3. After running the script, encrypt the merchant key using the wcs_encrypt.sh script:
    bash 
    ./wcs_encrypt.sh merchantKey KeyEncryptionKey 
    Where:
    merchantKey
    The plain text merchant key used in the initdb_db2_sample.sh script.
    KeyEncryptionKey
    Is your custom 32-character hexadecimal key.
    bash 
    ./wcs_encrypt.sh 1a1a1a1a1a1a1a1a2b2b2b2b2b2b2b2b 3c3c3c3c3c3c3c3c4d4d4d4d4d4d4d4d 
  4. For Kubernetes deployments, store the encrypted merchant key in your environment configuration.
    • In Vault: Store the value at the Tenant/EnvName/EnvType/merchantKeyEncrypted key path.
    • In values.yaml: Uncomment and update the merchantKey field with the encrypted value:
      yaml 
      merchantKey: ASCII_encrypted_string 

Results

The Commerce+ schema is loaded into your database.