0

私はすでにSpringでliquibase 3.0ベータ版を試しました(ところで、2.0では機能しませんでした)。うまくいきました。

現在、すべての変更をロールバックし、テーブル DATABASECHANGELOG と DATABASECHANGELOGLOCK を削除した後、同じデータベースと変更ログを使用して Ant でテストしています。

問題は、liquibaseがすべての変更セットをテーブル DATABASECHANGELOG に記録したことです。これは、 config にエラーがないことを意味しますが、変更をデータベースにコミットしませんでした。

これが私のchangelog.xmlファイルです:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog  http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">

  <preConditions>
    <dbms type="mysql"/>
  </preConditions>

  <changeSet id="1" author="bob" runAlways="true">
    <createTable tableName="department">
      <column name="id" type="int">
        <constraints primaryKey="true" nullable="false"/>
      </column>
      <column name="name" type="varchar(50)">
        <constraints nullable="false"/>
      </column>
      <column name="active" type="boolean" defaultValueBoolean="true"/>
    </createTable>
  </changeSet>

  <changeSet id="2" author="roger" runAlways="true">
    <comment>test add column</comment>
    <addColumn tableName="department">
      <column name="header" type="varchar(8)"/>
    </addColumn>
  </changeSet>

  <changeSet id="3" author="gabriel" runAlways="true">
    <createTable tableName="records">
      <column name="id" type="int" autoIncrement="true">
        <constraints primaryKey="true" nullable="false"/>
      </column>
      <column name="title" type="varchar(50)"/>
    </createTable>
  </changeSet>

  <changeSet id="4" author="gabriel" context="test" runAlways="true">
    <insert tableName="records">
      <column name="title" value="Liquibase 0.8 Released"/>
    </insert>
    <insert tableName="records">
      <column name="title" value="Liquibase 0.9 Released"/>
    </insert>
  </changeSet>

  <changeSet id="6" author="nvoxland" runAlways="true">
    <comment>test update eam_company</comment>
    <sql>update eam_company set companyName='haha' where companyId=15</sql>
  </changeSet>

</databaseChangeLog>

Ant build.xml ファイル:

<?xml version="1.0" encoding="utf-8"?>
<project name="ncpsys_v2" default="all">
  <!-- define time stamp -->
  <tstamp>
    <format property="current.time" pattern="yyyy_MM_dd_HH_mm_ss"/>
  </tstamp>

  <!-- define varibles and path -->
  <property file="liquibaseconf.properties"/>
  <path id="ant.classpath">
    <fileset dir="${ant.home}">
      <include name="**/*.jar"/>
    </fileset>
  </path>

  <target name="sync-database">
    <fail unless="db.changelog.file">db.changelog.file not set</fail>
    <fail unless="database.url">database.url not set</fail>
    <fail unless="database.username">database.username not set</fail>
    <fail unless="database.password">database.password not set</fail>
    <taskdef resource="liquibasetasks.properties">
      <classpath refid="ant.classpath"/>
    </taskdef>
    <changeLogSync changeLogFile="${db.changelog.file}" driver="${database.driver}" url="${database.url}" username="${database.username}" password="${database.password}" promptOnNonLocalDatabase="true" defaultSchemaName="root" classpathref="ant.classpath">
     </changeLogSync>
  </target>

  <target name="all" depends="sync-database"/>
</project>

liquibasetasks.properties ファイル

local.dir=.
#gwt.home=E:/work/libaray/gwt-2.3.0
jdk.home.1.6=C:/Program Files/Java/jdk1.6.0_10
ant_home=D:/software/apache-ant-1.8.3
tomcat.home=C:/Program Files/Apache Software Foundation/apache-tomcat-6.0.36

#liquibase config
database.driver=com.mysql.jdbc.Driver
database.url=jdbc:mysql://localhost:3306/ncpsys_v2?useUnicode=true&characterEncoding=UTF-8
database.username=root
database.password=1234
db.changelog.file=changelog.xml

Ant タスクを実行すると、liquibase によってテーブル DATABASECHANGELOG と DATABASECHANGELOGLOCK が作成され、 DATABASECHANGELOG にログが挿入されました。

Toad for MySQL に表示されたレコード

私のビルドログ:

sync-database:
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Successfully acquired change log lock
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Creating database history table with name: `ncpsys_v2`.`DATABASECHANGELOG`
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Reading from `ncpsys_v2`.`DATABASECHANGELOG`
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Reading from `ncpsys_v2`.`DATABASECHANGELOG`
[changeLogSync] INFO 13-4-2 下午1:22:liquibase: Successfully released change log lock

all:

BUILD SUCCESSFUL

Total time: 2 seconds

しかし、変更はデータベースで発生しませんでした。テーブル RECORDS と DEPARTMENT が作成され、データが挿入されているのを確認できませんでした。更新SQLも適用されませんでした。

私が間違ったことはありますか?それとも、バージョン 3.0beta1 で修正されていないバグがありますか?

この質問を liquibase フォーラムに投稿しましたが、回答が得られませんでした。

私を助けてください!私はすべて混乱しました。

4

1 に答える 1

1

changeLogSync ANT タスクを実行しています。次のように説明します。

データベースに対して実行されたすべての変更セットをマークします。データベースを手動で更新した場合に便利です。

これは、データベースに何もコミットされなかった理由を説明しています。代わりにupdateDatabaseタスクを使用するべきだったと思います

于 2013-04-08T18:23:16.577 に答える