./bin/ninja.sh run-sql \
--jdbc-url jdbc:postgresql://localhost:5432/postgres \
--jdbc-username postgres \
--jdbc-password postgres \
--scripts ./custom-upgrade-database.sql
Run SQL
run-sql
command can be used to execute SQL scripts on database.
Database schema changes are implemented in SQL scripts that are bundled with distribution in folder doc/config/sql/native/*.sql
.
User can use --mode [repository|audit]
switch together with --upgrade
to run proper scripts automatically or use --scripts
option to specify custom set of scripts.
Run-sql command can be used also to create database schema from scratch using switch --create
.
Ninja by default uses repository/audit configuration from midpoint-home/config.xml to connect to database.
This behaviour can be changed via --jdbc-url
, --jdbc-username
and --jdbc-password
options.
With these options, ninja will switch to raw mode, create custom JDBC connection and execute scripts on it.
If --result
switch is used, ninja will print results for each query in script to SYSOUT, otherwise results are ignored.
./bin/ninja.sh run-sql \
--mode repository \
--upgrade
./bin/ninja.sh run-sql \
--mode audit \
--upgrade
./bin/ninja.sh run-sql \
--mode repository \
--scripts ./upgrade/new-distribution/doc/config/sql/native/postgres-upgrade.sql