#1441 - Update ebean-dbmigration.xsd adding missing alterForeignKey element

This commit is contained in:
rob bygrave
2018-06-27 00:23:36 +12:00
parent 1a03e84f0e
commit ff3c5b3d82
4 changed files with 39 additions and 2 deletions
@@ -25,9 +25,9 @@ public class AlterForeignKey {
protected String name;
@XmlAttribute(name = "columnNames", required = true)
protected String columnNames;
@XmlAttribute(name = "refColumnNames", required = true)
@XmlAttribute(name = "refColumnNames")
protected String refColumnNames;
@XmlAttribute(name = "refTableName", required = true)
@XmlAttribute(name = "refTableName")
protected String refTableName;
@XmlAttribute(name = "indexName")
protected String indexName;
@@ -141,6 +141,19 @@
</xsd:complexType>
</xsd:element>
<xsd:element name="alterForeignKey">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="columnNames" type="xsd:string"/>
<xsd:attribute name="refColumnNames" type="xsd:string"/>
<xsd:attribute name="refTableName" type="xsd:string"/>
<xsd:attribute name="indexName" type="xsd:string"/>
<xsd:attribute name="tableName" type="xsd:string" use="required"/>
<xsd:attribute name="onDelete" type="xsd:string"/>
<xsd:attribute name="onUpdate" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="dropTable">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" use="required"/>
@@ -300,6 +313,7 @@
<xsd:element ref="addHistoryTable" maxOccurs="unbounded"/>
<xsd:element ref="dropHistoryTable" maxOccurs="unbounded"/>
<xsd:element ref="alterForeignKey" maxOccurs="unbounded"/>
<xsd:element ref="addColumn" maxOccurs="unbounded"/>
<xsd:element ref="dropColumn" maxOccurs="unbounded"/>
@@ -72,6 +72,13 @@ public class ModelContainerTest {
assertThat(container.getPendingDrops()).isEmpty();
}
@Test
public void apply_alterForeignKey() {
ModelContainer container = new ModelContainer();
container.apply(mig("4.0__alterForeignKey.model.xml"), ver("4.0"));
assertThat(container.getPendingDrops()).isEmpty();
}
private ModelContainer container_2_1() {
ModelContainer container = new ModelContainer();
container.apply(mig("2.0.model.xml"), ver("2.0"));
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
<changeSet type="apply">
<createTable name="document" withHistory="true" pkName="pk_document">
<column name="id" type="bigint" primaryKey="true" references="document_draft.id" foreignKeyName="fk_document_id"/>
<column name="title" type="varchar(255)" unique="uq_document_title"/>
<column name="body" type="varchar(255)"/>
<column name="zing" type="varchar(255)"/>
<column name="zong" type="varchar(255)"/>
<column name="version" type="bigint" notnull="true"/>
<column name="when_created" type="timestamp" notnull="true"/>
<column name="when_modified" type="timestamp" notnull="true"/>
</createTable>
<alterForeignKey name="fk_document_id" columnNames="DROP FOREIGN KEY" tableName="document"/>
</changeSet>
</migration>