Skip to content

Commit

Permalink
Only update metadata table ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
cjllanwarne committed Sep 21, 2023
1 parent fd386cd commit 836f084
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 34 deletions.
6 changes: 0 additions & 6 deletions database/migration/src/main/resources/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@
<!-- REMINDER!
Before appending here, did you remember to include the 'objectQuotingStrategy="QUOTE_ALL_OBJECTS"' line in your changeset/xyz.xml...?
-->
<!-- WARNING!
This changeset should always be last. It it always run (and should always run last) to set table ownership correctly:
-->
<include file="changesets/set_table_role.xml" relativeToChangelogFile="true" />


</databaseChangeLog>
<!--
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog objectQuotingStrategy="QUOTE_ALL_OBJECTS"
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-3.3.xsd">

<!-- The 'sharedCromwellDbRole' can be set via JAVA_OPTS if desired (eg -DsharedCromwellDbRole=...). -->
<property name="sharedCromwellDbRole" value=""/>

<!--
This changeset will be applied whenever the 'sharedCromwellDbRole' property is set.
It runs every time to ensure the role is set correctly after all other changesets.
-->
<changeSet runAlways="true" author="sshah" id="set_table_role" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<!-- check that 'sharedCromwellDbRole' role is set, and matches something in the pg_roles table -->
<sqlCheck expectedResult="1">
SELECT count(1)
FROM pg_roles
where '${sharedCromwellDbRole}' != '' and pg_roles.rolname = '${sharedCromwellDbRole}';
</sqlCheck>
</preConditions>
<sql>
ALTER TABLE "CUSTOM_LABEL_ENTRY" OWNER TO '${sharedCromwellDbRole}';
ALTER TABLE "METADATA_ENTRY" OWNER TO '${sharedCromwellDbRole}';
ALTER TABLE "SUMMARY_QUEUE_ENTRY" OWNER TO '${sharedCromwellDbRole}';
ALTER TABLE "SUMMARY_STATUS_ENTRY" OWNER TO '${sharedCromwellDbRole}';
ALTER TABLE "WORKFLOW_METADATA_SUMMARY_ENTRY" OWNER TO '${sharedCromwellDbRole}';
ALTER TABLE "sqlmetadatadatabasechangelog" OWNER TO '${sharedCromwellDbRole}';
ALTER TABLE "sqlmetadatadatabasechangeloglock" OWNER TO '${sharedCromwellDbRole}';
</sql>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<include file="metadata_changesets/update_metadata_archive_index.xml" relativeToChangelogFile="true" />
<include file="metadata_changesets/reset_archive_statuses_to_null.xml" relativeToChangelogFile="true" />
<!-- WARNING!
This changeset should always be last. It it always run (and should always run last) to set table ownership correctly:
This changeset should always be last.
It it always run (and should always run last) to set table ownership correctly.
If your changeset adds a new table, make sure it is also owned by the sharedCromwellDbRole.
-->
<include file="metadata_changesets/set_table_role.xml" relativeToChangelogFile="true" />

Expand Down

0 comments on commit 836f084

Please sign in to comment.