Skip to content
Permalink
Browse files
Merge pull request #15 from Izakey/FINCN-124
Migrate portfolio service from MariaDB to PostgreSQL
  • Loading branch information
Izakey committed Sep 2, 2019
2 parents 96b775f + 6831ea4 commit 77d203c7cf9e450a303b6a573283322fc4bb9147
Showing 27 changed files with 52 additions and 37 deletions.
@@ -2,6 +2,7 @@
.idea
build/
target/

api/out/
component-test/out/
service/out
@@ -1,5 +1,5 @@
Apache Fineract CN Portfolio
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/).
@@ -118,7 +118,7 @@ public Logger logger() {

@ClassRule
public final static TenantDataStoreContextTestRule tenantDataStoreContext
= TenantDataStoreContextTestRule.forRandomTenantName(cassandraInitializer, mariaDBInitializer);
= TenantDataStoreContextTestRule.forRandomTenantName(cassandraInitializer, postgreSQLInitializer);

@Rule
public final TenantApplicationSecurityEnvironmentTestRule tenantApplicationSecurityEnvironment
@@ -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;
@@ -33,11 +33,11 @@ public class SuiteTestEnvironment {
static final String APP_NAME = "portfolio-v1";
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));
}
@@ -61,7 +61,8 @@ dependencies {
[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.frameworkmariadb],
[group: 'org.apache.fineract.cn', name: 'postgresql', version: '0.1.0-BUILD-SNAPSHOT'],
[group: 'org.apache.fineract.cn', name: 'command', version: versions.frameworkcommand],
[group: 'org.hibernate', name: 'hibernate-validator', version: versions.validator],
[group: 'net.jodah', name: 'expiringmap', version: versions.expiringmap],
@@ -27,7 +27,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;

/**
* @author Myrle Krantz
@@ -30,7 +30,7 @@
import org.apache.fineract.cn.lang.config.EnableApplicationName;
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.apache.fineract.cn.rhythm.api.v1.client.RhythmManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,7 +52,7 @@
@EnableDiscoveryClient
@EnableAsync
@EnableTenantContext
@EnableMariaDB
@EnablePostgreSQL
@EnableCassandra
@EnableCommandProcessing
@EnableAnubis
@@ -26,7 +26,7 @@
import org.apache.fineract.cn.command.annotation.CommandHandler;
import org.apache.fineract.cn.command.annotation.CommandLogLevel;
import org.apache.fineract.cn.command.annotation.EventEmitter;
import org.apache.fineract.cn.mariadb.domain.FlywayFactoryBean;
import org.apache.fineract.cn.postgresql.domain.FlywayFactoryBean;
import org.flywaydb.core.Flyway;
import org.springframework.beans.factory.annotation.Autowired;

@@ -27,7 +27,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;

/**
* @author Myrle Krantz
@@ -32,7 +32,7 @@
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.apache.fineract.cn.mariadb.util.LocalDateTimeConverter;
import org.apache.fineract.cn.postgresql.util.LocalDateTimeConverter;

/**
* @author Myrle Krantz
@@ -38,7 +38,7 @@ public interface CaseRepository extends JpaRepository<CaseEntity, Long> {
Page<CaseEntity> findByProductIdentifierAndCurrentStateIn(String productIdentifier, Collection<String> currentStates, Pageable pageRequest);

//TODO: It should be possible to delete the @Query once we've updated to spring-data-release train ingalls.
@Query("SELECT COUNT(t) > 0 FROM CaseEntity t WHERE t.productIdentifier = :productIdentifier")
@Query("SELECT CASE WHEN COUNT(t) > 0 THEN true ELSE false END FROM CaseEntity t WHERE t.productIdentifier = :productIdentifier")
boolean existsByProductIdentifier(@Param("productIdentifier") String productIdentifier);

Stream<CaseEntity> findByCurrentStateIn(Collection<String> currentStates);
@@ -35,7 +35,7 @@
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.apache.fineract.cn.mariadb.util.LocalDateTimeConverter;
import org.apache.fineract.cn.postgresql.util.LocalDateTimeConverter;

/**
* @author Myrle Krantz
@@ -30,7 +30,7 @@
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.fineract.cn.mariadb.util.LocalDateTimeConverter;
import org.apache.fineract.cn.postgresql.util.LocalDateTimeConverter;

/**
* @author Myrle Krantz
@@ -34,6 +34,18 @@
# limitations under the License.
#

spring:
cloud:
discovery:
enabled: false
config:
enabled: false
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/playground
username: postgres
password: postgres

eureka:
client:
serviceUrl:
@@ -54,13 +66,13 @@ cassandra:
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
@@ -18,7 +18,7 @@
--

CREATE TABLE bastet_il_late_cases (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
case_id BIGINT NOT NULL,
late_since TIMESTAMP(3) NOT NULL,

@@ -18,7 +18,7 @@
--

CREATE TABLE bastet_il_c_docs (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
case_id BIGINT NOT NULL,
customer_identifier VARCHAR(32) NOT NULL,
document_identifier VARCHAR(32) NOT NULL,
@@ -17,10 +17,10 @@
-- under the License.
--

# noinspection SqlNoDataSourceInspectionForFile
/*# noinspection SqlNoDataSourceInspectionForFile*/

CREATE TABLE bastet_products (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
identifier VARCHAR(32) NOT NULL,
a_name VARCHAR(256) NOT NULL,
term_range_temporal_unit VARCHAR(128) NOT NULL,
@@ -46,7 +46,7 @@ CREATE TABLE bastet_products (
);

CREATE TABLE bastet_p_acct_assigns (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
designator VARCHAR(32) NOT NULL,
identifier VARCHAR(34) NOT NULL,
product_id BIGINT NOT NULL,
@@ -57,7 +57,7 @@ CREATE TABLE bastet_p_acct_assigns (
);

CREATE TABLE bastet_p_task_defs (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
identifier VARCHAR(32) NOT NULL,
product_id BIGINT NOT NULL,
a_name VARCHAR(256) NOT NULL,
@@ -71,7 +71,7 @@ CREATE TABLE bastet_p_task_defs (
);

CREATE TABLE bastet_p_chrg_defs (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
identifier VARCHAR(32) NOT NULL,
product_id BIGINT NOT NULL,
a_name VARCHAR(256) NOT NULL,
@@ -90,7 +90,7 @@ CREATE TABLE bastet_p_chrg_defs (
);

CREATE TABLE bastet_cases (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
identifier VARCHAR(32) NOT NULL,
product_identifier VARCHAR(32) NOT NULL,
current_state VARCHAR(32) NOT NULL,
@@ -103,7 +103,7 @@ CREATE TABLE bastet_cases (
);

CREATE TABLE bastet_c_acct_assigns (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
designator VARCHAR(32) NOT NULL,
identifier VARCHAR(34) NOT NULL,
case_id BIGINT NOT NULL,
@@ -113,7 +113,7 @@ CREATE TABLE bastet_c_acct_assigns (
);

CREATE TABLE bastet_il_cases (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
case_id BIGINT NOT NULL,
customer_identifier VARCHAR(32) NOT NULL,
term_range_temporal_unit VARCHAR(128) NOT NULL,
@@ -131,7 +131,7 @@ CREATE TABLE bastet_il_cases (
);

CREATE TABLE bastet_il_c_credit_facts (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
case_id BIGINT NOT NULL,
customer_identifier VARCHAR(32) NOT NULL,
position_in_factor INT NOT NULL,
@@ -17,6 +17,6 @@
-- under the License.
--

# noinspection SqlNoDataSourceInspectionForFile
/*# noinspection SqlNoDataSourceInspectionForFile*/

ALTER TABLE bastet_p_chrg_defs ADD COLUMN proportional_to VARCHAR(32) NULL DEFAULT NULL;
@@ -18,7 +18,7 @@
--

CREATE TABLE bastet_c_task_insts (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
case_id BIGINT NOT NULL,
task_def_id BIGINT NOT NULL,
a_comment VARCHAR(4096) NOT NULL,
@@ -18,7 +18,7 @@
--

CREATE TABLE bastet_p_balance_segs (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
seg_set_identifier VARCHAR(32) NOT NULL,
segment_identifier VARCHAR(32) NOT NULL,
product_id BIGINT NOT NULL,
@@ -18,7 +18,7 @@
--

CREATE TABLE bastet_case_commands (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
case_id BIGINT NOT NULL,
action_name VARCHAR(32) NOT NULL,
created_on TIMESTAMP(3) NOT NULL,
@@ -31,7 +31,7 @@ CREATE TABLE bastet_case_commands (
);

CREATE TABLE bastet_p_arrears_config (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
product_id BIGINT NOT NULL,
days_late INT NOT NULL,
percent_provision DECIMAL(5,2) NOT NULL,
@@ -66,7 +66,8 @@ ext['spring-data-releasetrain.version'] = 'Gosling-SR2A'

dependencies {
compile(
[group: 'com.google.code.findbugs', name: 'jsr305']
[group: 'com.google.code.findbugs', name: 'jsr305'],
[group: 'org.apache.fineract.cn', name: 'postgresql', version: '0.1.0-BUILD-SNAPSHOT']
)

testCompile(

0 comments on commit 77d203c

Please sign in to comment.