Merge pull request #9 from Izakey/FINCN-123

Migrate payroll service from MariaDB to PostgreSQL
diff --git a/NOTICE.txt b/NOTICE.txt
index acc95e4..94bb876 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,5 @@
 Apache Fineract CN Payroll
-Copyright [2017-2018] The Apache Software Foundation
+Copyright [2017-2019] The Apache Software Foundation
 
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file
diff --git a/component-test/src/main/java/org/apache/fineract/cn/payroll/AbstractPayrollTest.java b/component-test/src/main/java/org/apache/fineract/cn/payroll/AbstractPayrollTest.java
index 2030b48..7aa71fd 100644
--- a/component-test/src/main/java/org/apache/fineract/cn/payroll/AbstractPayrollTest.java
+++ b/component-test/src/main/java/org/apache/fineract/cn/payroll/AbstractPayrollTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.fineract.cn.payroll;
 
-
 import org.apache.fineract.cn.payroll.api.v1.EventConstants;
 import org.apache.fineract.cn.payroll.api.v1.client.PayrollManager;
 import org.apache.fineract.cn.payroll.service.PayrollServiceConfiguration;
@@ -74,8 +73,7 @@
 
   @ClassRule
   public final static TenantDataStoreContextTestRule tenantDataStoreContext =
-      TenantDataStoreContextTestRule.forRandomTenantName(SuiteTestEnvironment.cassandraInitializer,
-          SuiteTestEnvironment.mariaDBInitializer);
+      TenantDataStoreContextTestRule.forRandomTenantName(cassandraInitializer, postgreSQLInitializer);
 
   @Rule
   public final TenantApplicationSecurityEnvironmentTestRule tenantApplicationSecurityEnvironment
diff --git a/component-test/src/main/java/org/apache/fineract/cn/payroll/SuiteTestEnvironment.java b/component-test/src/main/java/org/apache/fineract/cn/payroll/SuiteTestEnvironment.java
index ebe1880..9f74c01 100644
--- a/component-test/src/main/java/org/apache/fineract/cn/payroll/SuiteTestEnvironment.java
+++ b/component-test/src/main/java/org/apache/fineract/cn/payroll/SuiteTestEnvironment.java
@@ -20,7 +20,7 @@
 
 import org.apache.fineract.cn.test.env.TestEnvironment;
 import org.apache.fineract.cn.test.fixture.cassandra.CassandraInitializer;
-import org.apache.fineract.cn.test.fixture.mariadb.MariaDBInitializer;
+import org.apache.fineract.cn.test.fixture.postgresql.PostgreSQLInitializer;
 import org.junit.ClassRule;
 import org.junit.rules.RuleChain;
 import org.junit.rules.RunExternalResourceOnce;
@@ -38,11 +38,11 @@
 
   static final TestEnvironment testEnvironment = new TestEnvironment(APP_NAME);
   static final CassandraInitializer cassandraInitializer = new CassandraInitializer();
-  static final MariaDBInitializer mariaDBInitializer = new MariaDBInitializer();
+  static final PostgreSQLInitializer postgreSQLInitializer = new PostgreSQLInitializer();
 
   @ClassRule
   public static TestRule orderClassRules = RuleChain
       .outerRule(new RunExternalResourceOnce(testEnvironment))
       .around(new RunExternalResourceOnce(cassandraInitializer))
-      .around(new RunExternalResourceOnce(mariaDBInitializer));
+      .around(new RunExternalResourceOnce(postgreSQLInitializer));
 }
diff --git a/service/build.gradle b/service/build.gradle
index 0b514d9..b314f83 100644
--- a/service/build.gradle
+++ b/service/build.gradle
@@ -57,7 +57,7 @@
             [group: 'org.apache.fineract.cn', name: 'lang', version: versions.frameworklang],
             [group: 'org.apache.fineract.cn', name: 'async', version: versions.frameworkasync],
             [group: 'org.apache.fineract.cn', name: 'cassandra', version: versions.frameworkcassandra],
-            [group: 'org.apache.fineract.cn', name: 'mariadb', version: versions.frameworkmariadb],
+            [group: 'org.apache.fineract.cn', name: 'postgresql', version: versions.frameworkpostgresql],
             [group: 'org.apache.fineract.cn', name: 'command', version: versions.frameworkcommand],
             [group: 'org.hibernate', name: 'hibernate-validator', version: versions.validator]
     )
diff --git a/service/src/main/java/org/apache/fineract/cn/payroll/service/PayrollServiceConfiguration.java b/service/src/main/java/org/apache/fineract/cn/payroll/service/PayrollServiceConfiguration.java
index ab36995..4c3c8f1 100644
--- a/service/src/main/java/org/apache/fineract/cn/payroll/service/PayrollServiceConfiguration.java
+++ b/service/src/main/java/org/apache/fineract/cn/payroll/service/PayrollServiceConfiguration.java
@@ -26,7 +26,7 @@
 import org.apache.fineract.cn.customer.api.v1.client.CustomerManager;
 import org.apache.fineract.cn.lang.config.EnableServiceException;
 import org.apache.fineract.cn.lang.config.EnableTenantContext;
-import org.apache.fineract.cn.mariadb.config.EnableMariaDB;
+import org.apache.fineract.cn.postgresql.config.EnablePostgreSQL;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -46,7 +46,7 @@
 @EnableAsync
 @EnableTenantContext
 @EnableCassandra
-@EnableMariaDB
+@EnablePostgreSQL
 @EnableCommandProcessing
 @EnableAnubis
 @EnableServiceException
diff --git a/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/command/handler/MigrationAggregate.java b/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/command/handler/MigrationAggregate.java
index ba185a4..2ac075e 100644
--- a/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/command/handler/MigrationAggregate.java
+++ b/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/command/handler/MigrationAggregate.java
@@ -25,7 +25,7 @@
 import org.apache.fineract.cn.command.annotation.CommandHandler;
 import org.apache.fineract.cn.command.annotation.EventEmitter;
 import org.apache.fineract.cn.lang.ApplicationName;
-import org.apache.fineract.cn.mariadb.domain.FlywayFactoryBean;
+import org.apache.fineract.cn.postgresql.domain.FlywayFactoryBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
diff --git a/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/repository/PayrollCollectionEntity.java b/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/repository/PayrollCollectionEntity.java
index 92fdad3..7411d61 100644
--- a/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/repository/PayrollCollectionEntity.java
+++ b/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/repository/PayrollCollectionEntity.java
@@ -26,7 +26,7 @@
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
-import org.apache.fineract.cn.mariadb.util.LocalDateTimeConverter;
+import org.apache.fineract.cn.postgresql.util.LocalDateTimeConverter;
 
 @Entity
 @Table(name = "meketre_payroll_collections")
diff --git a/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/repository/PayrollConfigurationEntity.java b/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/repository/PayrollConfigurationEntity.java
index aaf99fa..7defa32 100644
--- a/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/repository/PayrollConfigurationEntity.java
+++ b/service/src/main/java/org/apache/fineract/cn/payroll/service/internal/repository/PayrollConfigurationEntity.java
@@ -26,7 +26,7 @@
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
-import org.apache.fineract.cn.mariadb.util.LocalDateTimeConverter;
+import org.apache.fineract.cn.postgresql.util.LocalDateTimeConverter;
 
 @Entity
 @Table(name = "meketre_payroll_configurations")
diff --git a/service/src/main/resources/application.yml b/service/src/main/resources/application.yml
index 482a7e3..b7193af 100644
--- a/service/src/main/resources/application.yml
+++ b/service/src/main/resources/application.yml
@@ -23,6 +23,11 @@
       enabled: false
     config:
       enabled: false
+  datasource:
+    driver-class-name: org.postgresql.Driver
+    url: jdbc:postgresql://localhost:5432/playground
+    username: postgres
+    password: postgres
 
 eureka:
   client:
@@ -42,13 +47,13 @@
     write: LOCAL_QUORUM
     delete: LOCAL_QUORUM
 
-mariadb:
-  driverClass: org.mariadb.jdbc.Driver
+postgresql:
+  driverClass: org.postgresql.Driver
   database: seshat
   host: localhost
-  port: 3306
-  user: root
-  password: mysql
+  port: 5432
+  user: postgres
+  password: postgres
 
 bonecp:
   idleMaxAgeInMinutes: 240
diff --git a/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql b/service/src/main/resources/db/migrations/postgresql/V1__initial_setup.sql
similarity index 90%
rename from service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
rename to service/src/main/resources/db/migrations/postgresql/V1__initial_setup.sql
index 91ca05e..2ce02d9 100644
--- a/service/src/main/resources/db/migrations/mariadb/V1__initial_setup.sql
+++ b/service/src/main/resources/db/migrations/postgresql/V1__initial_setup.sql
@@ -18,7 +18,7 @@
 --
 
 CREATE TABLE meketre_payroll_configurations (
-  id                  BIGINT       NOT NULL AUTO_INCREMENT,
+  id                  BIGSERIAL    NOT NULL,
   customer_identifier VARCHAR(32)  NOT NULL,
   main_account_number VARCHAR(34)  NOT NULL,
   created_by          VARCHAR(32)  NOT NULL,
@@ -30,7 +30,7 @@
 );
 
 CREATE TABLE meketre_payroll_allocations (
-  id                       BIGINT        NOT NULL AUTO_INCREMENT,
+  id                       BIGSERIAL     NOT NULL,
   payroll_configuration_id BIGINT        NOT NULL,
   account_number           VARCHAR(34)   NOT NULL,
   amount                   NUMERIC(15,5) NOT NULL,
@@ -41,7 +41,7 @@
 );
 
 CREATE TABLE meketre_payroll_collections (
-  id                    BIGINT       NOT NULL AUTO_INCREMENT,
+  id                    BIGSERIAL    NOT NULL,
   identifier            VARCHAR(32)  NOT NULL,
   source_account_number VARCHAR(34)  NOT NULL,
   created_by            VARCHAR(32)  NOT NULL,
@@ -51,7 +51,7 @@
 );
 
 CREATE TABLE meketre_payroll_payments (
-  id                    BIGINT        NOT NULL AUTO_INCREMENT,
+  id                    BIGSERIAL     NOT NULL,
   payroll_collection_id BIGINT        NOT NULL,
   customer_identifier   VARCHAR(32)   NOT NULL,
   employer              VARCHAR(256)  NOT NULL,
diff --git a/service/src/main/resources/db/migrations/mariadb/V2__add_distribution_processing_behavior.sql b/service/src/main/resources/db/migrations/postgresql/V2__add_distribution_processing_behavior.sql
similarity index 100%
rename from service/src/main/resources/db/migrations/mariadb/V2__add_distribution_processing_behavior.sql
rename to service/src/main/resources/db/migrations/postgresql/V2__add_distribution_processing_behavior.sql
diff --git a/shared.gradle b/shared.gradle
index 9d6ba9a..eb3fd8a 100644
--- a/shared.gradle
+++ b/shared.gradle
@@ -23,7 +23,7 @@
         frameworklang : '0.1.0-BUILD-SNAPSHOT',
         frameworkasync : '0.1.0-BUILD-SNAPSHOT',
         frameworkcassandra : '0.1.0-BUILD-SNAPSHOT',
-        frameworkmariadb : '0.1.0-BUILD-SNAPSHOT',
+        frameworkpostgresql : '0.1.0-BUILD-SNAPSHOT',
         frameworkcommand : '0.1.0-BUILD-SNAPSHOT',
         frameworktest: '0.1.0-BUILD-SNAPSHOT',
         frameworkanubis: '0.1.0-BUILD-SNAPSHOT',
@@ -63,7 +63,8 @@
 
 dependencies {
     compile(
-            [group: 'com.google.code.findbugs', name: 'jsr305']
+            [group: 'com.google.code.findbugs', name: 'jsr305'],
+            [group: 'org.apache.fineract.cn', name: 'postgresql', version: versions.frameworkpostgresql]
     )
 
     testCompile(