Skip to content

Commit

Permalink
add support for XML-based changelogs
Browse files Browse the repository at this point in the history
this provides the necessary XSD. note that the XSD has to be published
at
http://www.liquibase.org/xml/ns/opensearch/liquibase-opensearch-1.0.xsd
for the reference to be valid for consumers. this seems to have been
done for other plugins (e.g. mongodb) but is - presumably? - a manual
process.
  • Loading branch information
rursprung committed Sep 13, 2024
1 parent 7b68250 commit d7b8d16
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.liquibase.org/xml/ns/opensearch"
xmlns="http://www.liquibase.org/xml/ns/opensearch"
elementFormDefault="qualified">

<xsd:simpleType name="httpMethods" final="restriction">
<xsd:restriction base="xsd:string">
<!--
as per https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
the following methods have been intentionally skipped as they cannot be used to modify data in OpenSearch:
GET, HEAD, CONNECT, OPTIONS, TRACE
-->
<xsd:enumeration value="POST" />
<xsd:enumeration value="PUT" />
<xsd:enumeration value="DELETE" />
<xsd:enumeration value="PATCH" />
</xsd:restriction>
</xsd:simpleType>

<xsd:element name="httpRequest">
<xsd:complexType>
<xsd:all>
<xsd:element name="method" type="httpMethods" />
<xsd:element name="path" type="xsd:string" />
<xsd:element name="body" type="xsd:string" />
</xsd:all>
</xsd:complexType>
</xsd:element>

</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@ public void itCreatesTheChangelogAndLockIndices() {

@SneakyThrows
@Test
public void itExecutesAHttpRequestAndCreatesTheIndex() {
public void itExecutesAHttpRequestAndCreatesTheIndexWithYAMLChangelog() {
this.doLiquibaseUpdate("liquibase/ext/changelog.httprequest.yaml");
assertThat(this.indexExists("testindex")).isTrue();
}

@SneakyThrows
@Test
public void itExecutesAHttpRequestAndCreatesTheIndexWithXMLChangelog() {
this.doLiquibaseUpdate("liquibase/ext/changelog.httprequest.xml");
assertThat(this.indexExists("xmltestindex")).isTrue();
}

@SneakyThrows
@Test
public void itHandlesReRuns() {
Expand Down
27 changes: 27 additions & 0 deletions src/test/resources/liquibase/ext/changelog.httprequest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:opensearch="http://www.liquibase.org/xml/ns/opensearch"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.29.xsd
http://www.liquibase.org/xml/ns/opensearch http://www.liquibase.org/xml/ns/opensearch/liquibase-opensearch-1.0.xsd">

<changeSet id="10000" author="test" labels="XMLhttpRequestLabel" context="httpRequestContext">
<comment>httpRequestComment</comment>
<opensearch:httpRequest>
<opensearch:method>PUT</opensearch:method>
<opensearch:path>/xmltestindex</opensearch:path>
<opensearch:body>
{
"mappings": {
"properties": {
"testfield": {
"type": "text"
}
}
}
}
</opensearch:body>
</opensearch:httpRequest>
</changeSet>

</databaseChangeLog>

0 comments on commit d7b8d16

Please sign in to comment.