PostgreSQL is an open-source Object-relational database system and provides good performance with low maintenance efforts because of its high stability. The Kill Bill core team uses MySQL, but we also run regression tests against MariaDB 10 and PostgreSQL 14. This document has detailed instructions to setup PostgreSQL with Kill Bill and Kaui.

PostgreSQL Kill Bill Configuration

In order to configure PostgreSQL with Kill Bill, you need to follow the steps given below (These steps can be executed either via the command line psql tool or via pgAdmin):

  1. Create a user corresponding to Kill Bill. You can run the following command :

     CREATE ROLE killbilluser WITH LOGIN INHERIT CREATEDB CREATEROLE NOREPLICATION PASSWORD 'killbill';
  2. Create a database corresponding to Kill Bill. You can run the following command:

     CREATE DATABASE killbill WITH OWNER = killbilluser;
  3. Connect to the Kill Bill database created above. In psql, you can run the following:

      \connect killbill;
  4. Create the Kill Bill schema. Run the following command:

      CREATE SCHEMA killbillschema authorization killbilluser;
  5. Connect to the schema created above using the following command:

      set schema 'killbillschema';
  6. Execute this schema extension DDL.

  7. Run the Kill Bill DDL here. In psql, you can run the following command:

      \i <ddl_file_path>
  8. Grant privileges to the schema using the following command:

      GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA killbillschema TO killbilluser;
      GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA killbillschema TO killbilluser;

PostgreSQL Kaui Configuration

In order to configure PostgreSQL, you need to follow the steps given below (These steps can be executed either via the command line psql tool or via pgAdmin):

  1. Create a database corresponding to kaui. You can run the following command:

     CREATE DATABASE kaui WITH OWNER = killbilluser;
  2. Connect to the kaui database created above. In psql, you can run the following:

      \connect kaui;
  3. Create the Kill Bill schema. Run the following command:

      CREATE SCHEMA killbillschema authorization killbilluser;
  4. Connect to the schema created above using the following command:

      set schema 'killbillschema';
  5. Execute this schema extension DDL.

  6. Run the Kaui DDL here.

  7. Grant privileges to the schema using the following command:

      GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA killbillschema TO killbilluser;
      GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA killbillschema TO killbilluser;
  8. Modify the PROJECT_ROOT/profiles/killbill/src/main/resources/killbill-server.properties OR TOMCAT_HOME/conf/catalina.properties as the case may be. Add the following properties :

     #KAUI postgresql section
      kaui.db.url=jdbc:postgresql://127.0.0.1:5432/kaui
      kaui.db.username=killbilluser
      kaui.db.password=killbill
  9. Set the DB adapter to override for PostgreSQL instead of the defaut Mysql in either PROJECT_ROOT/profiles/killbill/src/main/resources/killbill-server.properties OR TOMCAT_HOME/conf/catalina.properties as the case may be :

      kaui.db.adapter=postgresql
  10. Set the Search Path to killbillschema. Run the below command as postgres user

      ALTER USER killbilluser SET search_path TO killbillschema;