Skip to content

Commit

Permalink
Building patch v2.43.3_patch1
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Nov 1, 2023
1 parent 394237e commit 90b12f5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions orcid-persistence/src/main/resources/db-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,5 @@
<include file="/db/updates/create_email_domain_mapping_tables.xml" />
<include file="/db/updates/create_event_table.xml" />
<include file="/db/updates/dw_event.xml" />
<include file="/db/updates/dw_alter_event.xml" />
</databaseChangeLog>
43 changes: 43 additions & 0 deletions orcid-persistence/src/main/resources/db/updates/dw_alter_event.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<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-2.0.xsd">

<changeSet id="ALTER-DW-EVENT-VIEW-GROUP-BY-DAY-CLIENT_ID-AND-EVENT_TYPE" author="Daniel Palafox" dbms="postgresql">
<dropView viewName="dw_event"/>

<createView viewName="dw_event">
SELECT event_type, client_id, COUNT(id), DATE_TRUNC('day', date_created), DATE_TRUNC('day', date_created) as last_modified
FROM event
WHERE event_type != 'Public-Page'
GROUP BY event_type, client_id, DATE_TRUNC('day', date_created)
ORDER BY DATE_TRUNC('day', date_created) DESC;
</createView>
</changeSet>

<changeSet id="GRANT-READ-TO-DW_USER-TO-DW_EVENT-VIEW" author="Daniel Palafox" dbms="postgresql">
<preConditions>
<sqlCheck expectedResult="1">SELECT 1 FROM pg_roles WHERE rolname='dw_user'</sqlCheck>
</preConditions>
<sql>GRANT SELECT ON TABLE dw_event to dw_user;</sql>
</changeSet>

<changeSet id="ALTER-DW-EVENT-VIEW-GROUP-BY-PUBLIC-PAGE" author="Daniel Palafox" dbms="postgresql">
<dropView viewName="dw_event_public_page"/>

<createView viewName="dw_event_public_page">
SELECT event_type, public_page, COUNT(id), DATE_TRUNC('day', date_created), DATE_TRUNC('day', date_created) as last_modified
FROM event
WHERE event_type = 'Public-Page'
GROUP BY event_type, public_page, DATE_TRUNC('day', date_created)
ORDER BY DATE_TRUNC('day', date_created) DESC;
</createView>
</changeSet>

<changeSet id="GRANT-READ-TO-DW-EVENT-VIEW-GROUP-BY-PUBLIC-PAGE" author="Daniel Palafox" dbms="postgresql">
<preConditions>
<sqlCheck expectedResult="1">SELECT 1 FROM pg_roles WHERE rolname='dw_user'</sqlCheck>
</preConditions>
<sql>GRANT SELECT ON TABLE dw_event_public_page to dw_user;</sql>
</changeSet>

</databaseChangeLog>

0 comments on commit 90b12f5

Please sign in to comment.