Skip to main content
Version: 8.8.x

Set up a Local Database

Required

This step is required for team developers and individual developers.

Self-Managed Commerce supports multiple database engines. Choose one engine and follow its section. Then create the database schema.

Each section runs the database in a Docker container. Docker must be installed and running. See Install Development Tools.

note

The commands on this page use the password mysecretpassword. Change it to a more secure value.

MySQL​

  1. Run the MySQL Docker image.

    For MySQL 8.4:

    docker run --name mysql-84-db --env="MYSQL_ROOT_PASSWORD=mysecretpassword" -p 3306:3306 -d mysql:8.4 --transaction_isolation=READ-COMMITTED --lower_case_table_names=1 --max_connections=1000

    For MySQL 8.0:

    docker run --name mysql-80-db --env="MYSQL_ROOT_PASSWORD=mysecretpassword" -p 3306:3306 -d mysql:8.0 --transaction_isolation=READ-COMMITTED --lower_case_table_names=1 --max_connections=1000
  2. Edit ~/.m2/settings.xml:

    1. In the <activeProfiles> section, make sure that mysql-dev-db is active. Comment out all other profiles that end with -dev-db.
    2. In the mysql-dev-db profile, set epdb.reset_password to the password from step 1.

PostgreSQL​

  1. Run the PostgreSQL Docker image. The POSTGRES_DB variable creates the COMMERCEDB database.

    docker run --name postgresql-16-db --env="POSTGRES_PASSWORD=mysecretpassword" --env="POSTGRES_DB=COMMERCEDB" -p 5432:5432 -d postgres:16 -c max_connections=1000
  2. Edit ~/.m2/settings.xml:

    1. In the <activeProfiles> section, uncomment postgresql-dev-db. Comment out all other profiles that end with -dev-db.

    2. In the postgresql-dev-db profile, make sure that epdb.reset_user is postgres. Set epdb.reset_password to the password from step 1.

    3. The epdb.schemaname property is public by default. You can change it to a different schema name.

      note

      PostgreSQL converts the schema name to lowercase.

  3. Optional: To browse the database, install pgAdmin and connect with these values:

    • Username: postgres
    • Password: The password from step 1.
    • Hostname: localhost
    • Port: 5432

Oracle​

The Docker image depends on your workstation:

Run Oracle on Apple Silicon​

  1. Run the Oracle Docker image:

    docker run -d --name oracle-19-db -p 1521:1521 -e ORACLE_PWD=mysecretpassword codeassertion/oracledb-arm64-standalone:19.3.0-enterprise
  2. Follow Wait for Oracle to Start.

Run Oracle on Other Systems​

The Oracle image is in the Oracle Container Registry. You must sign in and accept the license before you can download it.

  1. Sign in to the Oracle Container Registry with your Oracle account.

  2. Go to Database > enterprise and accept the license agreement.

  3. Sign in to the registry from Docker. Use your Oracle account email and password.

    docker login container-registry.oracle.com
  4. Run the Oracle Docker image:

    docker run -d --name oracle-19-db -p 1521:1521 -e ORACLE_PWD=mysecretpassword container-registry.oracle.com/database/enterprise:19.3.0.0
  5. Follow Wait for Oracle to Start.

Wait for Oracle to Start​

  1. Make sure that the oracle-19-db container is in the output of docker ps.

  2. Watch the container logs:

    docker logs -f oracle-19-db

    The first start can take several minutes. When the logs show DATABASE IS READY TO USE!, Oracle is ready.

Set Max String Size to Extended​

  1. Open a terminal in the Docker container:

    docker exec -it oracle-19-db bash
  2. In the container terminal, run these commands:

    export ORACLE_SID=ORCLCDB
    sqlplus sys/mysecretpassword as sysdba
  3. In sqlplus, run these commands one at a time to start the EXTENDED mode upgrade:

    ALTER SESSION SET CONTAINER=CDB$ROOT;
    ALTER SYSTEM SET max_string_size=extended SCOPE=SPFILE;
    SHUTDOWN IMMEDIATE
    STARTUP UPGRADE
    quit
  4. In the container terminal, run these commands to finish the EXTENDED mode upgrade for the pluggable databases:

    cd $ORACLE_HOME/rdbms/admin
    $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS --force_pdb_mode 'UPGRADE' -d $ORACLE_HOME/rdbms/admin -b utl32k_cdb_pdbs_output utl32k.sql
    sqlplus sys/mysecretpassword as sysdba
  5. In sqlplus, run these commands one at a time to restart the database:

    SHUTDOWN IMMEDIATE
    STARTUP
    quit
  6. In the container terminal, run these commands to finish the EXTENDED mode upgrade for the main database:

    cd $ORACLE_HOME/rdbms/admin
    $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS --force_pdb_mode 'READ WRITE' -d $ORACLE_HOME/rdbms/admin -b utlrp_cdb_pdbs_output utlrp.sql
  7. Exit the container terminal:

    exit

Configure Maven for Oracle​

  1. Edit ~/.m2/settings.xml:

    1. In the <activeProfiles> section, uncomment oracle-dev-db. Comment out all other profiles that end with -dev-db.
    2. In the oracle-dev-db profile, set epdb.reset_password to the password from the docker run command.

    The oracle-dev-db profile must contain these properties. The templates in extensions/maven already contain them.

    <profile>
    <id>oracle-dev-db</id>
    <properties>
    <epdb.host>localhost</epdb.host>
    <epdb.port>1521</epdb.port>
    <epdb.databasename>ORCLPDB1</epdb.databasename>
    <epdb.username>COMMERCEDB</epdb.username>
    <epdb.password>ep</epdb.password>
    <epdb.reset_databasename>ORCLCDB</epdb.reset_databasename>
    <epdb.reset_user>sys as sysdba</epdb.reset_user>
    <epdb.reset_password>mysecretpassword</epdb.reset_password>
    <epdb.default.tablespace>COMMERCE</epdb.default.tablespace>
    <epdb.temporary.tablespace>COMMERCETEMP</epdb.temporary.tablespace>
    <ep.database.timezone>UTC</ep.database.timezone>
    </properties>
    </profile>
  2. Optional: To browse the database, install SQL Developer and connect with these values:

    • Username: COMMERCEDB
    • Password: ep
    • Hostname: localhost
    • Port: 1521
    • Service name: ORCLPDB1

Create the Database Schema​

Do this step for all database engines.

  1. Go to the extensions/database directory of the ep-commerce source code.

  2. Run this command:

    mvn clean install -Preset-db

Stop and Start the Database​

A stopped database container keeps its data. To stop the container, run docker stop <container-name>. To start it again, run docker start <container-name>. For example:

docker stop oracle-19-db
docker start oracle-19-db

Next Step​

Set up IntelliJ IDEA. This step is optional. To skip it, go to Building Self-Managed Commerce.