Skip to content

Commit

Permalink
#374 - Update example/sample xml for xml schema changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave committed Aug 7, 2015
1 parent f6c3279 commit c0d4dac
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/test/resources/container/test-create-table.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ebean-orm.github.io/xml/ns/dbmigration http://ebean-orm.github.io/xml/ns/dbmigration-1.0.xsd">

<changeSet id="1">
<changeSet type="apply">

<createTable name="foo" withHistory="true" tablespace="fooSpace" indexTablespace="fooIndexSpace" remarks="comment">
<createTable name="foo" withHistory="true" tablespace="fooSpace" indexTablespace="fooIndexSpace" comment="comment">
<column name="col1" type="varchar(4)" notnull="true" primaryKey="true"/>
<column name="col2" type="varchar(30)" notnull="true"/>
<column name="col3" type="varchar(30)" notnull="true"/>
Expand Down
60 changes: 60 additions & 0 deletions src/test/resources/dbmigration/app1/v1.0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ebean-orm.github.io/xml/ns/dbmigration http://ebean-orm.github.io/xml/ns/dbmigration-1.0.xsd">

<changeSet type="apply" generated="true">

<sql>
<apply>
create table foo;
</apply>
<rollback>
drop table if exists foo;
</rollback>
</sql>

<createTable name="dbmigration">
<column name="application" type="varchar(30)" notnull="true"/>
<column name="change_log" type="integer" notnull="true"/>
<column name="change_set" type="integer" notnull="true"/>
<column name="locked_by" type="varchar(30)"/>
<column name="locked_at" type="timestamp"/>
</createTable>

<createTable name="dbmigration_changeset">
<column name="id" type="integer" primaryKey="true"/>
<column name="application" type="varchar(30)" notnull="true" references="dbmigration.application"/>
<column name="change_log" type="integer" notnull="true"/>
<column name="change_set" type="integer" notnull="true"/>
<column name="run_at" type="timestamp" notnull="true"/>
<column name="run_by" type="varchar(30)" notnull="true"/>
<column name="run_ddl" type="clob"/>
<column name="run_log" type="clob"/>
</createTable>

<createTable name="hello_world" withHistory="true">
<column name="id" type="integer" primaryKey="true"/>
<column name="name" type="varchar(20)" notnull="true"/>
<column name="type" type="varchar(20)" notnull="true"/>
<column name="description" type="varchar(20)" notnull="true"/>
<uniqueConstraint columnNames="name,type"/>
</createTable>

<addColumn tableName="hello_world">
<column name="fooe" type="varchar(20)"/>
</addColumn>


<createHistoryTable baseTable="hello_world"/>

<addForeignKey name="fk_hello_world_x" columns="x" references="asdsad.asd"/>

</changeSet>

<changeSet type="drop" generated="true">

<dropColumn columnName="fooe" tableName="hello_world"/>

</changeSet>

</migration>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ebean-orm.github.io/xml/ns/dbmigration http://ebean-orm.github.io/xml/ns/dbmigration-1.0.xsd">

<changeSet id="1">
<changeSet type="apply">

<sql>
<apply>
Expand Down Expand Up @@ -44,12 +44,17 @@
<column name="fooe" type="varchar(20)"/>
</addColumn>

<dropColumn columnName="fooe" tableName="hello_world"/>

<createHistoryTable baseTable="hello_world"/>

<addForeignKey name="fk_hello_world_x" columns="x" references="asdsad.asd"/>

</changeSet>

<changeSet type="drop" generated="true">

<dropColumn columnName="fooe" tableName="hello_world"/>

</changeSet>

</migration>
53 changes: 53 additions & 0 deletions src/test/resources/dbmigration/app1/v10.0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ebean-orm.github.io/xml/ns/dbmigration http://ebean-orm.github.io/xml/ns/dbmigration-1.0.xsd">

<changeSet type="apply">

<sql>
<apply>
create table foo;
</apply>
<rollback>
drop table if exists foo;
</rollback>
</sql>

<createTable name="dbmigration_lock">
<column name="application" type="varchar(30)" notnull="true"/>
<column name="locked_by" type="varchar(30)"/>
<column name="locked_at" type="timestamp"/>
</createTable>

<createTable name="dbmigration_run">
<column name="id" type="integer" primaryKey="true"/>
<column name="application" type="varchar(30)" notnull="true" references="dbmigration.application"/>
<column name="version" type="varchar(3)" notnull="true"/>
<column name="run_at" type="timestamp" notnull="true"/>
<column name="run_by" type="varchar(30)" notnull="true"/>
<column name="run_status" type="varchar(30)" notnull="true"/>
<column name="run_ddl" type="clob"/>
<column name="run_log" type="clob"/>
</createTable>

<createTable name="hello_world" withHistory="true">
<column name="id" type="integer" primaryKey="true"/>
<column name="name" type="varchar(20)" notnull="true"/>
<column name="description" type="varchar(20)" notnull="true"/>
</createTable>

<addColumn tableName="hello_world">
<column name="fooe" type="varchar(20)"/>
</addColumn>

<dropColumn columnName="fooe" tableName="hello_world"/>

<createHistoryTable baseTable="hello_world"/>

</changeSet>

<changeSet type="drop" generated="true">
<!-- no drops to do -->
</changeSet>

</migration>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ebean-orm.github.io/xml/ns/dbmigration http://ebean-orm.github.io/xml/ns/dbmigration-1.0.xsd">

<changeSet id="1">
<changeSet type="apply">

<sql>
<apply>
Expand Down Expand Up @@ -48,4 +48,8 @@

</changeSet>

<changeSet type="drop" generated="true">
<!-- no drops to do -->
</changeSet>

</migration>
55 changes: 55 additions & 0 deletions src/test/resources/dbmigration/app1/v9.0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ebean-orm.github.io/xml/ns/dbmigration http://ebean-orm.github.io/xml/ns/dbmigration-1.0.xsd">

<changeSet type="apply">

<sql>
<apply>
create table foo;
</apply>
<rollback>
drop table if exists foo;
</rollback>
</sql>

<createTable name="dbmigration">
<column name="application" type="varchar(30)" notnull="true"/>
<column name="change_log" type="integer" notnull="true"/>
<column name="change_set" type="integer" notnull="true"/>
<column name="locked_by" type="varchar(30)"/>
<column name="locked_at" type="timestamp"/>
</createTable>

<createTable name="dbmigration_changeset">
<column name="id" type="integer" primaryKey="true"/>
<column name="application" type="varchar(30)" notnull="true" references="dbmigration.application"/>
<column name="change_log" type="integer" notnull="true"/>
<column name="change_set" type="integer" notnull="true"/>
<column name="run_at" type="timestamp" notnull="true"/>
<column name="run_by" type="varchar(30)" notnull="true"/>
<column name="run_ddl" type="clob"/>
<column name="run_log" type="clob"/>
</createTable>

<createTable name="hello_world" withHistory="true">
<column name="id" type="integer" primaryKey="true"/>
<column name="name" type="varchar(20)" notnull="true"/>
<column name="description" type="varchar(20)" notnull="true"/>
</createTable>

<addColumn tableName="hello_world">
<column name="fooe" type="varchar(20)"/>
</addColumn>

<dropColumn columnName="fooe" tableName="hello_world"/>

<createHistoryTable baseTable="hello_world"/>

</changeSet>

<changeSet type="drop" generated="true">
<!-- no drops to do -->
</changeSet>

</migration>
18 changes: 18 additions & 0 deletions src/test/resources/dbmigration/myapp/v1.0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">

<changeSet type="baseline">

<createTable name="mig_country">
<column name="code" type="varchar(2)" primaryKey="true" />
<column name="name" type="varchar(255)"/>
<column name="longName" type="varchar(1000)"/>
</createTable>

</changeSet>

<changeSet type="drop" generated="true">
<!-- no drops to do -->
</changeSet>

</migration>
40 changes: 40 additions & 0 deletions src/test/resources/dbmigration/myapp/v2.0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">

<changeSet type="apply" generated="true">

<createTable name="mig_account">
<column name="id" type="bigint" primaryKey="true" identity="true"/>
<column name="name" type="varchar(255)"/>
<column name="when_created" type="timestamp" notnull="true" />
<column name="when_modified" type="timestamp" notnull="true" />
<column name="version" type="bigint" notnull="true" />
</createTable>

<createTable name="mig_address" withHistory="true">
<column name="id" type="integer" primaryKey="true" identity="true"/>
<column name="line_1" type="varchar(100)"/>
<column name="line_2" type="varchar(100)"/>
<column name="city" type="varchar(100)"/>
<column name="country_code" type="varchar(2)" references="o_country.code" />
<column name="when_created" type="timestamp" notnull="true"/>
<column name="when_updated" type="timestamp" notnull="true"/>
<column name="version" type="bigint" notnull="true"/>
</createTable>

<addColumn tableName="mig_country">
<column name="status" type="varchar(5)"/>
</addColumn>

<createHistoryTable baseTable="mig_country" whenCreatedColumn="when_created"/>

</changeSet>


<changeSet type="drop" generated="true">

<dropColumn columnName="longName" tableName="mig_address"/>

</changeSet>

</migration>

0 comments on commit c0d4dac

Please sign in to comment.