./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
The run-sql command executes SQL scripts on the midPoint database.
Database schema changes are performed using SQL scripts that are bundled with the distribution and stored in doc/config/sql/native/*.sql folder.
User selects the scripts to run using the following options:
-
--createexecutes scripts that create the database schema from scratch. -
--upgradeupgrades an existing database schema.-
You can combine this with
--modeset to eitherREPOSITORYorAUDITto upgrade repository or audit schema selectively.
-
The run-sql command can be also used to execute custom scripts using the --scripts option, which accepts a path to an SQL script file.
|
The script set specified using the |
The --result option prints the results of executed SQL statements (including query output) to the standard output (SYSOUT).
This option is particularly useful when executing custom SQL scripts using the --scripts option, as it allows users to inspect query results directly from the command line.
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 you do not want to provide the password directly on the command line, use the --jdbc-ask-password option.
Ninja will prompt you to enter the password interactively, preventing it from being displayed in the command history or process list.
./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