<?xml version="1.0" encoding="UTF-8"?>

<migration>

  <databank>
    <source
      url="jdbc:mysql://127.0.0.1/DATABASE_SRC?user=USERNAME&amp;password=PASSWORD"
      driver="org.gjt.mm.mysql.Driver"
    />
    <target
      url="jdbc:mysql://127.0.0.1/DATABASE_TGT?user=USERNAME&amp;password=PASSWORD"
      driver="org.gjt.mm.mysql.Driver"
    />
  </databank>

  <functions>
      <!-- simple function declaration -->
      <function name="countrows"
                sql="select count(*) from source_table where id > 0" />
      <!--
        function using values of the current record.
        To reference values of the current record we use ${current.FIELD_NAME}
      -->
      <function name="count_greater_rows"
                sql="select count(*) from source_table where id > ${current.id}" />
  </functions>

  <steps>
    <!--
      a step is the copy of data from a table to another
      we can have as many as we want

      if "clear_target" is true, all data from target table will be lost
      before the copy starts. Default value: false.

      "output" can take values: "db", "file", "both".
      If file or both, a file with name STEP_NAME.sql will be created will all
      insert senteces. Default value: db.
    -->
    <step name="test_migration"
          source_table="source_table"
          target_table="target_table"
          clear_target="true"
          output="file"
     >
      <!-- normal copy fields -->
      <field from="id" to="item" type="int" value=""/>
      <field from="datum" to="post-date" type="date" value=""/>
      <field from="text" to="description" type="string" value=""/>
      <!-- setting new values -->
      <field from="" to="user" type="new-string" value="anonymous"/>
      <field from="" to="today" type="new-date" value="2002-11-25"/>
      <field from="" to="intvalue" type="new-int" value="0"/>
      <!--
        setting values from funtions.
        A function will be referenced with ${FUNCTIONS_NAME}
        You should use always types "new-xxxx" with fuctions.
      -->
      <field from="" to="count" type="new-int" value="${countrows}"/>
    </step>
  </steps>

</migration>
