dependency-track/dev/scripts/dbschema-generate.sh
nscuro df196b5ec8
Move Compose files and scripts to dev directory
To make it clear that these Compose files are only meant for dev and testing work. Avoiding confusion with the existing `src/main/docker/docker-compose.yml`, which is also used as quickstart.

Signed-off-by: nscuro <nscuro@protonmail.com>
2023-05-29 18:46:14 +02:00

43 lines
No EOL
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
DEFAULT_OUTPUT="./schema.sql"
DEFAULT_DNPROPS="./dev/scripts/dbschema-generate.datanucleus.properties"
function printHelp() {
echo "Generate the database schema for Dependency-Track."
echo ""
echo "Usage: $0 [-o <OUTPUT_FILE>] [-p <PROPERTIES_FILE>]"
echo "Options:"
echo " -o Set output path for the schema (default: $DEFAULT_OUTPUT)"
echo " -p Set path to DataNucleus properties (default: $DEFAULT_DNPROPS)"
echo ""
echo "This script uses the DataNucleus schema tool:"
echo " https://www.datanucleus.org/products/accessplatform/jdo/persistence.html#schematool"
echo ""
}
while getopts ":h:o:p:" opt; do
case $opt in
o)
output=$OPTARG
;;
p)
dnprops=$OPTARG
;;
h)
printHelp
exit
;;
*)
printHelp
exit
;;
esac
done
mvn datanucleus:schema-create \
-DpersistenceUnitName=Alpine \
-Dprops="${dnprops:-$DEFAULT_DNPROPS}" \
-DcompleteDdl=true \
-DddlFile="${output:-$DEFAULT_OUTPUT}" \
-Dlog4jConfiguration=./dev/scripts/dbschema-generate.log4j.properties