Skip to content
Permalink
Browse files
Merge pull request #12 from Izakey/FINCN-126
Migrate teller service from MariaDB to PostgreSQL
  • Loading branch information
Izakey committed Sep 2, 2019
2 parents 030ae07 + 7a5caee commit 0b48c64a43714f9e8241de7796cd517ad75b80ba
Showing 16 changed files with 41 additions and 47 deletions.
@@ -1,5 +1,5 @@
Apache Fineract CN Teller
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/).
@@ -80,7 +80,7 @@ public Logger logger() {
static final String TEST_USER = "homer";

@ClassRule
public static TenantDataStoreContextTestRule tenantDataStoreContext = TenantDataStoreContextTestRule.forRandomTenantName(cassandraInitializer, mariaDBInitializer);
public static TenantDataStoreContextTestRule tenantDataStoreContext = 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 = "teller-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));
}
@@ -60,7 +60,7 @@ 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.frameworkpostgresql],
[group: 'org.apache.fineract.cn', name: 'command', version: versions.frameworkcommand],
[group: 'org.apache.fineract.cn', name: 'crypto', version: versions.frameworkcrypto],
[group: 'org.hibernate', name: 'hibernate-validator', version: versions.validator]
@@ -28,7 +28,7 @@
import org.apache.fineract.cn.deposit.api.v1.client.DepositAccountManager;
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.office.api.v1.client.OrganizationManager;
import org.apache.fineract.cn.portfolio.api.v1.client.PortfolioManager;
import org.slf4j.Logger;
@@ -50,7 +50,7 @@
@EnableAsync
@EnableTenantContext
@EnableCassandra
@EnableMariaDB
@EnablePostgreSQL
@EnableCommandProcessing
@EnableAnubis
@EnableServiceException
@@ -26,7 +26,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.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -29,7 +29,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;

@Entity
@Table(name = "tajet_teller_denominations")
@@ -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;

@Entity
@Table(name = "tajet_teller")
@@ -31,7 +31,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;

@Entity
@Table(name = "tajet_teller_transactions")
@@ -23,6 +23,11 @@ spring:
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 @@ 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 tajet_teller (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
identifier VARCHAR(32) NOT NULL,
a_password VARCHAR(4096) NOT NULL,
a_salt VARCHAR(4069) NOT NULL,
@@ -33,11 +33,10 @@ CREATE TABLE tajet_teller (
last_modified_on TIMESTAMP(3) NULL,
last_modified_by VARCHAR(32) NULL,
CONSTRAINT tajet_teller_pk PRIMARY KEY (id),
CONSTRAINT tajet_teller_identifier_uq UNIQUE (identifier)
);
CONSTRAINT tajet_teller_identifier_uq UNIQUE (identifier));

CREATE TABLE tajet_teller_transactions (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
teller_id BIGINT NOT NULL,
identifier VARCHAR(32) NOT NULL,
transaction_type VARCHAR(32) NOT NULL,
@@ -50,7 +49,6 @@ CREATE TABLE tajet_teller_transactions (
clerk VARCHAR(32) NOT NULL,
amount NUMERIC(15, 5) NOT NULL,
a_state VARCHAR(256) NOT NULL,
CONSTRAINT tajet_teller_transaction PRIMARY KEY (id),
CONSTRAINT tajet_teller_identifier_uq UNIQUE (identifier),
CONSTRAINT tajet_teller_transaction_fk FOREIGN KEY (teller_id) REFERENCES tajet_teller (id)
);
CONSTRAINT tajet_teller_transactions_pk PRIMARY KEY (id),
CONSTRAINT tajet_teller_identifier_unq UNIQUE (identifier),
CONSTRAINT tajet_teller_transaction_fk FOREIGN KEY (teller_id) REFERENCES tajet_teller (id));
@@ -18,7 +18,7 @@
--

CREATE TABLE tajet_cheques (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
teller_transaction_id BIGINT NOT NULL,
cheque_number VARCHAR(8) NOT NULL,
branch_sort_code VARCHAR(11) NOT NULL,
@@ -31,5 +31,4 @@ CREATE TABLE tajet_cheques (
open_cheque BOOLEAN NULL,
CONSTRAINT tajet_cheques_pk PRIMARY KEY (id),
CONSTRAINT tajet_cheques_uq UNIQUE (cheque_number, branch_sort_code, account_number),
CONSTRAINT tajet_cheques_teller_tx_fk FOREIGN KEY (teller_transaction_id) REFERENCES tajet_teller_transactions (id)
)
CONSTRAINT tajet_cheques_teller_tx_fk FOREIGN KEY (teller_transaction_id) REFERENCES tajet_teller_transactions (id));
@@ -17,10 +17,8 @@
-- under the License.
--

ALTER TABLE tajet_teller MODIFY teller_account_identifier VARCHAR(34);
ALTER TABLE tajet_teller MODIFY vault_account_identifier VARCHAR(34);
ALTER TABLE tajet_teller ALTER COLUMN teller_account_identifier TYPE VARCHAR(34);
ALTER TABLE tajet_teller ALTER COLUMN vault_account_identifier TYPE VARCHAR(34);
ALTER TABLE tajet_teller ADD cheques_receivable_account VARCHAR(34);


ALTER TABLE tajet_teller_transactions MODIFY customer_account_identifier VARCHAR(34);
ALTER TABLE tajet_teller_transactions MODIFY target_account_identifier VARCHAR(34);
ALTER TABLE tajet_teller_transactions ALTER COLUMN customer_account_identifier TYPE VARCHAR(34);
ALTER TABLE tajet_teller_transactions ALTER COLUMN target_account_identifier TYPE VARCHAR(34);
@@ -20,10 +20,4 @@
ALTER TABLE tajet_teller ADD last_opened_by VARCHAR(32) NULL;
ALTER TABLE tajet_teller ADD last_opened_on TIMESTAMP(3) NULL;

UPDATE
tajet_teller
SET
last_opened_by = last_modified_by,
last_opened_on = last_modified_on
WHERE
last_modified_on IS NOT NULL;
UPDATE tajet_teller SET last_opened_by = last_modified_by, last_opened_on = last_modified_on WHERE last_modified_on IS NOT NULL;
@@ -21,13 +21,12 @@ ALTER TABLE tajet_teller ADD cash_over_short_account VARCHAR(34) NULL;
ALTER TABLE tajet_teller ADD denomination_required BOOLEAN NOT NULL DEFAULT FALSE;

CREATE TABLE tajet_teller_denominations (
id BIGINT NOT NULL AUTO_INCREMENT,
id BIGSERIAL NOT NULL,
teller_id BIGINT NOT NULL,
counted_total NUMERIC(15,5) NOT NULL,
note VARCHAR(512) NULL,
adjusting_journal_entry VARCHAR(32) NULL,
created_on TIMESTAMP(3) NOT NULL,
created_by VARCHAR(32) NOT NULL,
CONSTRAINT tajet_teller_denominations PRIMARY KEY (id),
CONSTRAINT tajet_teller_denominations_fk FOREIGN KEY (teller_id) REFERENCES tajet_teller (id)
);
CONSTRAINT tajet_teller_denominations_pk PRIMARY KEY (id),
CONSTRAINT tajet_teller_denominations_fk FOREIGN KEY (teller_id) REFERENCES tajet_teller (id));
@@ -23,7 +23,7 @@ ext.versions = [
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',
frameworkcrypto: '0.1.0-BUILD-SNAPSHOT',
@@ -67,7 +67,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: versions.frameworkpostgresql]
)

testCompile(

0 comments on commit 0b48c64

Please sign in to comment.