You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2022/06/01 08:15:40 UTC

[GitHub] [fineract] adamsaghy commented on a diff in pull request #2344: Fineract with ReadOnly tenant database connection

adamsaghy commented on code in PR #2344:
URL: https://github.com/apache/fineract/pull/2344#discussion_r886518299


##########
fineract-provider/src/main/resources/db/changelog/tenant-store/parts/0004_readonly_database_connection.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership. The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied. See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
+    <changeSet author="fineract" id="add-readonly-database-connection-properties" context="tenant_store_db">
+        <addColumn tableName="tenant_server_connections">
+            <column name="readonly_schema_server" type="VARCHAR(100)"/>
+        </addColumn>
+        <addColumn tableName="tenant_server_connections">
+            <column name="readonly_schema_name" type="VARCHAR(100)"/>
+        </addColumn>
+        <addColumn tableName="tenant_server_connections">
+            <column name="readonly_schema_server_port" type="VARCHAR(10)"/>
+        </addColumn>
+        <addColumn tableName="tenant_server_connections">
+            <column name="readonly_schema_username" type="VARCHAR(10)"/>
+        </addColumn>
+        <addColumn tableName="tenant_server_connections">
+            <column name="readonly_schema_password" type="VARCHAR(100)"/>
+        </addColumn>
+    </changeSet>
+    <changeSet author="fineract" id="set-readonly-database-connection-properties" context="tenant_store_db">
+        <sql>
+            UPDATE tenant_server_connections SET readonly_schema_server=schema_server, readonly_schema_name=schema_name, readonly_schema_server_port=schema_server_port, readonly_schema_username=schema_username, readonly_schema_password=schema_password

Review Comment:
   Agree with you here. We should set either the proper values or null everywhere (if read only table functionality not to be used).
   However i would even further and do it this way:
   - Read the values from variables (same as we did for the default tenant)
   - Add runOnChange=true 
   - Add a precondition which removes the actual entry
   - Add onFail="WARN" to the precondition as if it is the first time when the changeset is executed there is no row to be deleted
   - Add the new entry (read only db settings)
   
   What we earn:
   - Our tenant connection settings will be resilient for changes
   - Our tenant connection settings will be updated on changes automatically
   
   If we are happy with this approach, i would suggest to apply the same changes to the original tenant connection changeset.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org