Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OMRS-131: Detailed Audit Logging (Updated) #4668

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

wikumChamith
Copy link
Contributor

Description of what I changed

I have enabled logging for tables that were omitted in the last PR. To identify these tables, I used the following SQL script to detect which tables lack corresponding audit tables:

SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'openmrs'
  AND table_name NOT LIKE '%_AUD'
  AND table_name NOT IN (
    SELECT SUBSTRING_INDEX(table_name, '_AUD', 1)
    FROM information_schema.tables
    WHERE table_schema = 'openmrs'
      AND table_name LIKE '%_AUD'
);

Here are the tables currently without audit tables:

  • OpenMRSRevisionEntity: This is a custom Hibernate Envers revision entity and does not require an audit table.
  • concept_proposal_tag_map: Lacks a corresponding Hibernate entity or mapping.
  • report_object: Lacks a corresponding Hibernate entity or mapping.
  • user_property: Encountered an error when generating audit tables.
  • report_schema_xml: Lacks a corresponding Hibernate entity or mapping.
  • scheduler_task_config_property: Encountered an error when generating audit tables.
  • liquibasechangeloglock: Lacks a corresponding Hibernate entity or mapping.
  • note: Lacks a corresponding Hibernate entity or mapping.
  • liquibasechangelog: Lacks a corresponding Hibernate entity or mapping.
  • medication_dispense: Although it generates an audit table, it results in a test error when auditing is enabled.

Issue I worked on

see https://openmrs.atlassian.net/browse/OMRS-131

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@dkayiwa
Copy link
Member

dkayiwa commented Jun 19, 2024

Can we rename the OpenMRSRevisionEntity table to match our table naming convention?

@dkayiwa
Copy link
Member

dkayiwa commented Jun 19, 2024

Can you raise a pull request with medication_dispense such that i see the failure on github? I have so far failed to reproduce it locally.

@@ -9,13 +9,16 @@
*/
package org.openmrs.scheduler;

import org.hibernate.envers.Audited;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using this anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are auditing Schedule entity

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where in the codebase are we using that entity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added auditing to it because it is used here:

<hibernate-mapping package="org.openmrs.scheduler">

However, I couldn't find any scheduler_schedule tables in the database.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it may be time to get rid of it. 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I delete both the class and hbm?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but in a separate pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a PR for this: #4670

@wikumChamith
Copy link
Contributor Author

@dkayiwa I updated the revision entity name.

@wikumChamith
Copy link
Contributor Author

Can you raise a pull request with medication_dispense such that i see the failure on github? I have so far failed to reproduce it locally.

I created a new PR for this: #4669

@@ -22,6 +23,7 @@
*/
@RevisionEntity(OpenMRSRevisionEntityListener.class)
@Entity
@Table(name = "openmrs_revision_entity")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the openmrs_ prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the PR.

@@ -22,6 +23,7 @@
*/
@RevisionEntity(OpenMRSRevisionEntityListener.class)
@Entity
@Table(name = "revision_entity")
public class OpenMRSRevisionEntity extends DefaultRevisionEntity {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And i think our naming convention has been Openmrs instead of OpenMRS. Not so? 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the class name.

@dkayiwa
Copy link
Member

dkayiwa commented Jun 19, 2024

@wikumChamith can we fix these merge conflicts?

Enabled logging to the tables that we did not include in last PR.
@dkayiwa dkayiwa merged commit 6d0637f into openmrs:master Jun 19, 2024
6 checks passed
Wandji69 pushed a commit to Wandji69/openmrs-core that referenced this pull request Jun 27, 2024
Enabled logging to the tables that we did not include in last PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants