Skip to content

Commit

Permalink
billing: database fixes necessitated by Liquibase update
Browse files Browse the repository at this point in the history
Motivation:

[Patch](https://rb.dcache.org/r/13594/) updating Liquibase to version
4.29 omitted a necessary checksum change for a changeset for the
optional billing system.

Modification:

* Create a new changeset for the billing system with highest priority to
  update the defective checksum in the DB prior to any other changesets
  being evaluated.

* Add a new `bean` to ensure that the new changeset is loaded prior to
  any others.

Result:

Billing system will start correctly with Liquibase 4.29.

Target: master
Patch: https://rb.dcache.org/r/
Requires-notes: no
Requires-book: no
Acked-by:
  • Loading branch information
greenc-FNAL committed Feb 4, 2025
1 parent 2440b22 commit 7e16e1d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@
<property name="hourlyAggregateDataHandler" ref="hourly-aggregata-data-handler"/>
</bean>

<bean id="liquibase" class="org.dcache.util.SpringLiquibase">
<bean id="liquibase-pre" class="org.dcache.util.SpringLiquibase">
<description>Database schema Pre-manager</description>
<property name="dataSource" ref="data-source"/>
<property name="changeLog" value="classpath:${billing.db.schema.changelog-pre}"/>
<property name="shouldUpdate" value="${billing.db.schema.auto}"/>
</bean>

<bean id="liquibase" class="org.dcache.util.SpringLiquibase" depends-on="liquibase-pre">
<description>Database schema manager</description>
<property name="dataSource" ref="data-source"/>
<property name="changeLog" value="classpath:${billing.db.schema.changelog}"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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.29.xsd">

<!--
IMPORTANT:
This file contains changes that should be applied prior any other schema changes,
typically to fix liquibase or schema issues that prevent other changes from being applied.
-->

<changeSet id="0.1" author="greenc-FNAL" runOrder="first">
<comment>
Fix liquibase issue with duplicate id and mismatching md5sums in databasechangelog table.
This change set should be applied before any other changes.
</comment>

<sql>
UPDATE databasechangelog SET md5sum = '7:4c38beef9de5e3dccd4b1b0b466d3a9f' WHERE md5sum = '7:9107e2c9760619db0aab6f1f9c1ff48f';
</sql>
</changeSet>
</databaseChangeLog>
3 changes: 3 additions & 0 deletions skel/share/defaults/billing.properties
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ billing.db.fine-grained-truncate-before=365
# To enable conditional presence of database for the dcache database commands
#

(immutable)billing.db.schema.changelog-pre-when-true=org/dcache/services/billing/db/sql/00-billing.changelog-pre.xml
(immutable)billing.db.schema.changelog-pre-when-false=
(immutable)billing.db.schema.changelog-when-true=org/dcache/services/billing/db/sql/billing.changelog-master.xml
(immutable)billing.db.schema.changelog-when-false=

Expand All @@ -498,6 +500,7 @@ billing.db.fine-grained-truncate-before=365
# the dcache database command will attempt to connect
# Hence this cannot be equal to billing.db.name in this case.
#
billing.db.schema.changelog-pre=${billing.db.schema.changelog-pre-when-${billing.enable.db}}
billing.db.schema.changelog=${billing.db.schema.changelog-when-${billing.enable.db}}

#
Expand Down

0 comments on commit 7e16e1d

Please sign in to comment.