Skip to main content

Setup Microservice Databases

Microservices typically make use of a variety of database stores. The following command will create the required databases, migrate them to the latest state, and fill them with relevant data.

nx run-many --target=prisma-generate --parallel=1

Once that has completed, run:

nx run-many --target=data-import

(Note: When running data-import, it is recommended that you run it from the main branch. This typically takes about 12 minutes.)

Once that has completed, run:

nx run-many --target=prisma-migrate
nx run-many --target=prisma-seed

Here are all the above commands, and the reset, in one script:

#!/bin/sh
nx run-many --target=prisma-reset
nx run-many --target=prisma-generate --parallel=1
nx run-many --target=data-import
nx run-many --target=prisma-migrate
nx run-many --target=prisma-seed

Common Issues

prisma-generate failing

If prisma-generate is failing, try running:

nx run-many --target=prisma-reset

command failed because of mmdc

If prisma generate fails with a error message similar to the one below:

Command failed: "/workspaces/core/node_modules/-bin/mmdc" -i "/tmp/prisma-erd-q0 cpUx/prisma.mmd" -0 "/workspaces/core/apis/api-journeys/db/ERD.svg" -c"/tmp/pri
sma-erd-qOcpUx/config-json" -p"/tmp/prisma-erd-qOcpUx/puppeteerConfig-json"

It is related to prisma-erd-generator attempting to run. Under the hood, it uses puppeteer and chromium to execute. The error this command is experiencing could be related to chromium not being installed, installed incorrectly, or not having the proper permissions to execute.

Here are some steps you can follow to resolve the issue:

  • run sudo apt-get -y install chromium
  • On Mac update Docker Desktop to at least 4.28.0
  • rebuild your container using latest main