Skip to content

Commit e86d453

Browse files
committed
chore(migrate): add migration for keywordTermUri and placeholder configuration #10288
Introduces a new migration script to update `keywordValue` fields containing HTTP values to `keywordTermUri` (as seen in the release notes). Updates the POM to include a placeholder for toggling this migration, ensuring flexibility during upgrades. Using a Flyway placeholder, we can inject a Maven property into the SQL script and conditionally execute the migration. Defaulting to false (don't execute). See also: https://documentation.red-gate.com/fd/migration-placeholders-275218550.html
1 parent c78f5df commit e86d453

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--
2+
DO
3+
$$
4+
DECLARE
5+
should_migrate BOOLEAN := CASE WHEN UPPER('${V6_3_migrate_keywordTermUri}') = 'TRUE' THEN TRUE ELSE FALSE END;
6+
BEGIN
7+
IF should_migrate THEN
8+
RAISE NOTICE 'Migrating keywordValue fields with http... to keywordTermUri as requested';
9+
UPDATE datasetfield df
10+
SET datasetfieldtype_id = (SELECT id FROM datasetfieldtype WHERE name = 'keywordTermURI')
11+
FROM datasetfieldvalue dfv
12+
WHERE dfv.datasetfield_id = df.id
13+
AND df.datasetfieldtype_id = (SELECT id FROM datasetfieldtype WHERE name = 'keywordValue')
14+
AND dfv.value ILIKE 'http%';
15+
END IF;
16+
END
17+
$$;

modules/dataverse-migrate-db/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<postgresql.dump.target>${project.build.directory}</postgresql.dump.target>
4343
<!-- Default: wait for 30s (DMP default is 10s) -->
4444
<postgresql.waitForSec>30</postgresql.waitForSec>
45+
46+
<!-- Migrations Placeholders -->
47+
<!-- See https://github.com/IQSS/dataverse/releases/tag/v6.3#upgrade-instructions-6-3, https://github.com/IQSS/dataverse/pull/10371 -->
48+
<migrate.keywordTermUri>false</migrate.keywordTermUri>
4549
</properties>
4650

4751
<build>
@@ -245,6 +249,9 @@
245249
<location>filesystem:../../src/main/resources/db/migration</location>
246250
<location>filesystem:extra-migrations</location>
247251
</locations>
252+
<placeholders>
253+
<V6_3_migrate_keywordTermUri>${migrate.keywordTermUri}</V6_3_migrate_keywordTermUri>
254+
</placeholders>
248255
</configuration>
249256
</execution>
250257
<execution>

0 commit comments

Comments
 (0)