dbdeploy

http://dbdeploy.com/

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2.   
  3. <project name="dbdeploy_tt" default="default">  
  4.     <property name="db.driver" value="com.mysql.jdbc.Driver" />  
  5.     <property name="db.url" value="jdbc:mysql://192.168.0.36:3306/webmanage?characterEncoding=utf8" />  
  6.     <property name="db.user" value="root" />  
  7.     <property name="db.password" value="" />  
  8.     <property name="db.path" value="." />  
  9.     <property name="dbdeploy_home" value="D:\program\dbdeploy-3.0M3\" />  
  10.     <path id="mysql.classpath">  
  11.         <fileset dir="${dbdeploy_home}">  
  12.             <include name="core/mysql-connector-java-5.1.11-bin.jar"/>  
  13.         </fileset>  
  14.     </path>  
  15.     <path id="dbdeploy.classpath">  
  16.         <!-- include the dbdeploy-ant jar -->  
  17.         <fileset dir="${dbdeploy_home}">  
  18.             <include name="core/dbdeploy-ant-*.jar"/>  
  19.         </fileset>  
  20.         <!-- the dbdeploy task also needs the database driver jar on the classpath -->  
  21.         <path refid="mysql.classpath" />  
  22.     </path>  
  23.   
  24.     <taskdef name="dbdeploy" classname="com.dbdeploy.AntTarget" classpathref="dbdeploy.classpath"/>  
  25.   
  26.     <target name="default" depends="update-step"/>  
  27.   
  28.     <target name="init" depends="create-changelog-table" description="初始化(create-changelog-table)"/>  
  29.   
  30.     <target name="create-changelog-table" description="建changelog">  
  31.         <sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.password}" classpathref="mysql.classpath" >  
  32.             <fileset file="${dbdeploy_home}core/createSchemaVersionTable.mysql.sql"/>  
  33.         </sql>  
  34.     </target>  
  35.   
  36.     <target name="update" description="直接执行">  
  37.   
  38.         <!-- if you don't specify an output file, dbdeploy will apply the changes for you   
  39.         you may need to specify delimiter and delimitertype for your scripts to be split properly - these   
  40.          work the same as in the ant sql task, see http://ant.apache.org/manual/CoreTasks/sql.html   
  41.         -->  
  42.         <dbdeploy driver="${db.driver}" url="${db.url}"  
  43.                   userid="${db.user}"  
  44.                   password="${db.password}"  
  45.                   dir="${db.path}"  
  46.                 />  
  47.   
  48.     </target>  
  49.   
  50.     <target name="update-step" description="生成前进,后退文件,并执行">  
  51.   
  52.         <!-- use dbdeploy to generate the change script -->  
  53.         <dbdeploy driver="${db.driver}" url="${db.url}"  
  54.                   userid="${db.user}"  
  55.                   password="${db.password}"  
  56.                   dir="${db.path}"  
  57.                   outputfile="output.sql"  
  58.                   undoOutputfile="undo.sql"  
  59.                   dbms="mysql"  
  60.                 />  
  61.   
  62.         <!-- now apply the changescript to the database -->  
  63.         <sql driver="${db.driver}" url="${db.url}" encoding="utf-8"  
  64.              userid="${db.user}" password="${db.password}" classpathref="mysql.classpath">  
  65.             <fileset file="output.sql"/>  
  66.         </sql>  
  67.   
  68.     </target>  
  69.   
  70.     <target name="undo" description="执行undo">  
  71.         <sql driver="${db.driver}" url="${db.url}" encoding="utf-8"  
  72.              userid="${db.user}" password="${db.password}" classpathref="mysql.classpath">  
  73.             <fileset file="undo.sql"/>  
  74.         </sql>  
  75.     </target>  
  76.   
  77.     <target name="redo" description="执行output.sql">  
  78.         <sql driver="${db.driver}" url="${db.url}" encoding="utf-8"  
  79.              userid="${db.user}" password="${db.password}" classpathref="mysql.classpath">  
  80.             <fileset file="output.sql"/>  
  81.         </sql>  
  82.     </target>  
  83.   
  84.     <target name="showlog" description="执行sql">  
  85.         <sql driver="${db.driver}" url="${db.url}" encoding="utf-8"  
  86.              userid="${db.user}" password="${db.password}" print="true" classpathref="mysql.classpath">  
  87.             select * from changelog;   
  88.         </sql>  
  89.     </target>  
  90.   
  91. </project>  
  1. da shang
    donate-alipay
               donate-weixin weixinpay

发表评论↓↓