FINERACT-1670: Add auditable fields to Business date

This commit is contained in:
Adam Saghy
2022-08-09 10:42:21 +02:00
committed by Aleksandar Vidakovic
parent 47d5a85f17
commit 5df284aad1
3 changed files with 77 additions and 2 deletions
@@ -28,12 +28,12 @@ import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
@Getter
@Entity
@Table(name = "m_business_date", uniqueConstraints = { @UniqueConstraint(name = "uq_business_date_type", columnNames = { "type" }) })
public class BusinessDate extends AbstractAuditableCustom {
public class BusinessDate extends AbstractAuditableWithUTCDateTimeCustom {
@Enumerated(EnumType.STRING)
@Column(name = "type")
@@ -49,4 +49,5 @@
<include file="parts/0027_add_charge_refund_permission.xml" relativeToChangelogFile="true"/>
<include file="parts/0028_add_charge_refund_charge_type_to_loan_transaction.xml" relativeToChangelogFile="true"/>
<include file="parts/0029_add_delinquency_buckets.xml" relativeToChangelogFile="true"/>
<include file="parts/0030_add_audit_entries_to_business_date.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
@@ -0,0 +1,74 @@
<?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.3.xsd">
<changeSet author="fineract" id="business_date-1" context="mysql">
<addColumn tableName="m_business_date">
<column name="created_on_utc" type="DATETIME"/>
<column name="last_modified_on_utc" type="DATETIME"/>
</addColumn>
</changeSet>
<changeSet author="fineract" id="business_date-1" context="postgresql">
<addColumn tableName="m_business_date">
<column name="created_on_utc" type="TIMESTAMP WITH TIME ZONE"/>
<column name="last_modified_on_utc" type="TIMESTAMP WITH TIME ZONE"/>
</addColumn>
</changeSet>
<changeSet id="business_date-2" author="fineract">
<dropNotNullConstraint tableName="m_business_date" columnName="created_date" columnDataType="datetime"/>
<dropNotNullConstraint tableName="m_business_date" columnName="lastmodified_date" columnDataType="datetime"/>
</changeSet>
<changeSet id="business_date-3" author="fineract">
<renameColumn tableName="m_business_date" oldColumnName="createdby_id" newColumnName="created_by" columnDataType="BIGINT"/>
<renameColumn tableName="m_business_date" oldColumnName="lastmodifiedby_id" newColumnName="last_modified_by" columnDataType="BIGINT"/>
</changeSet>
<changeSet author="fineract" id="business_date-4">
<addForeignKeyConstraint baseColumnNames="created_by" baseTableName="m_business_date"
constraintName="FK_business_date_created_by" deferrable="false" initiallyDeferred="false"
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
referencedTableName="m_appuser" validate="true"/>
<addForeignKeyConstraint baseColumnNames="last_modified_by" baseTableName="m_business_date"
constraintName="FK_business_date_last_modified_by" deferrable="false" initiallyDeferred="false"
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
referencedTableName="m_appuser" validate="true"/>
</changeSet>
<changeSet id="business_date-5" author="fineract" context="mysql">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from m_business_date</sqlCheck>
</preConditions>
<addNotNullConstraint tableName="m_business_date" columnName="created_on_utc" columnDataType="DATETIME"/>
<addNotNullConstraint tableName="m_business_date" columnName="last_modified_on_utc" columnDataType="DATETIME"/>
</changeSet>
<changeSet id="business_date-5" author="fineract" context="postgresql">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from m_business_date</sqlCheck>
</preConditions>
<addNotNullConstraint tableName="m_business_date" columnName="created_on_utc" columnDataType="TIMESTAMP WITH TIME ZONE"/>
<addNotNullConstraint tableName="m_business_date" columnName="last_modified_on_utc" columnDataType="TIMESTAMP WITH TIME ZONE"/>
</changeSet>
<changeSet id="business_date-6" author="fineract">
<addNotNullConstraint tableName="m_business_date" columnName="created_by" columnDataType="BIGINT"/>
<addNotNullConstraint tableName="m_business_date" columnName="last_modified_by" columnDataType="BIGINT"/>
</changeSet>
</databaseChangeLog>