Set up a Local Database
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.
The commands on this page use the password mysecretpassword. Change it to a more secure value.
MySQL
-
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=1000For 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 -
Edit
~/.m2/settings.xml:- In the
<activeProfiles>section, make sure thatmysql-dev-dbis active. Comment out all other profiles that end with-dev-db. - In the
mysql-dev-dbprofile, setepdb.reset_passwordto the password from step 1.
- In the
PostgreSQL
-
Run the PostgreSQL Docker image. The
POSTGRES_DBvariable creates theCOMMERCEDBdatabase.docker run --name postgresql-16-db --env="POSTGRES_PASSWORD=mysecretpassword" --env="POSTGRES_DB=COMMERCEDB" -p 5432:5432 -d postgres:16 -c max_connections=1000 -
Edit
~/.m2/settings.xml:-
In the
<activeProfiles>section, uncommentpostgresql-dev-db. Comment out all other profiles that end with-dev-db. -
In the
postgresql-dev-dbprofile, make sure thatepdb.reset_userispostgres. Setepdb.reset_passwordto the password from step 1. -
The
epdb.schemanameproperty ispublicby default. You can change it to a different schema name.notePostgreSQL converts the schema name to lowercase.
-
-
Optional: To browse the database, install pgAdmin and connect with these values:
Username:postgresPassword: The password from step 1.Hostname:localhostPort:5432
Oracle
The Docker image depends on your workstation:
- For a Mac with Apple silicon, follow Run Oracle on Apple Silicon.
- For Windows, Linux, or a Mac with an Intel processor, follow Run Oracle on Other Systems.
Run Oracle on Apple Silicon
-
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 -
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.
-
Sign in to the Oracle Container Registry with your Oracle account.
-
Go to Database > enterprise and accept the license agreement.
-
Sign in to the registry from Docker. Use your Oracle account email and password.
docker login container-registry.oracle.com -
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 -
Follow Wait for Oracle to Start.
Wait for Oracle to Start
-
Make sure that the
oracle-19-dbcontainer is in the output ofdocker ps. -
Watch the container logs:
docker logs -f oracle-19-dbThe first start can take several minutes. When the logs show
DATABASE IS READY TO USE!, Oracle is ready.
Set Max String Size to Extended
-
Open a terminal in the Docker container:
docker exec -it oracle-19-db bash -
In the container terminal, run these commands:
export ORACLE_SID=ORCLCDBsqlplus sys/mysecretpassword as sysdba -
In
sqlplus, run these commands one at a time to start theEXTENDEDmode upgrade:ALTER SESSION SET CONTAINER=CDB$ROOT;ALTER SYSTEM SET max_string_size=extended SCOPE=SPFILE;SHUTDOWN IMMEDIATESTARTUP UPGRADEquit -
In the container terminal, run these commands to finish the
EXTENDEDmode 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.sqlsqlplus sys/mysecretpassword as sysdba -
In
sqlplus, run these commands one at a time to restart the database:SHUTDOWN IMMEDIATESTARTUPquit -
In the container terminal, run these commands to finish the
EXTENDEDmode 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 -
Exit the container terminal:
exit
Configure Maven for Oracle
-
Edit
~/.m2/settings.xml:- In the
<activeProfiles>section, uncommentoracle-dev-db. Comment out all other profiles that end with-dev-db. - In the
oracle-dev-dbprofile, setepdb.reset_passwordto the password from thedocker runcommand.
The
oracle-dev-dbprofile must contain these properties. The templates inextensions/mavenalready 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> - In the
-
Optional: To browse the database, install SQL Developer and connect with these values:
Username:COMMERCEDBPassword:epHostname:localhostPort:1521Service name:ORCLPDB1
Create the Database Schema
Do this step for all database engines.
-
Go to the
extensions/databasedirectory of theep-commercesource code. -
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.