2

Flyway バージョン 2.1.1 を初めてテストしています。テーブルがまだ存在しない場合 (およびスキーマに存在しない場合) にテーブルmigrateを作成するAnt タスクを使用していますが、次のエラーが発生します。schema_version

C:\Users\dmusiani\Desktop\flyaway-test>ant
Buildfile: build.xml

migrate-db:
[flyway:migrate] com.googlecode.flyway.core.api.FlywayException: Found non-empty
 schema "SYSTEM" without metadata table! Use init() first to initialize the meta
data table.

BUILD FAILED
C:\Users\dmusiani\Desktop\flyaway-test\build.xml:37: Flyway Error: com.googlecod
e.flyway.core.api.FlywayException: Found non-empty schema "SYSTEM" without metad
ata table! Use init() first to initialize the metadata table.

Total time: 0 seconds
C:\Users\dmusiani\Desktop\flyaway-test>

init移行前にを追加しようとしましたが、最初はすべて機能しましたが、ビルドを 2 回目に起動するinitと、テーブルが既に存在するというエラーが表示されます。

これが私のAntターゲットです:

<target name="migrate-db">

    <path id="flyway.lib.path">
        <fileset dir="./lib">
            <include name="**/flyway*.jar"/>
        </fileset>
    </path>

    <path id="flyway.classpath">
        <fileset dir="./lib" includes="ojdbc6-11.2.0.3.jar"/>
    </path>

    <taskdef uri="antlib:com.googlecode.flyway.ant"
             resource="com/googlecode/flyway/ant/antlib.xml"
             classpathref="flyway.lib.path"/>

    <flyway:init  driver="oracle.jdbc.OracleDriver"
                     url="jdbc:oracle:thin:@localhost:1521:WBMD"
                     user="system"
                     password="manager" 
                     initVersion="0"
                     initDescription="Version table initialization (table &quot;USERNAME&quot;.&quot;schema_version&quot; )"/>

    <flyway:migrate driver="oracle.jdbc.driver.OracleDriver"
                     url="jdbc:oracle:thin:@localhost:1521:WBMD"
                     user="system"
                     password="manager"
                     sqlMigrationPrefix="patch" >
        <locations>
            <location path="integrations-runtime/HELIOS/1-9-0/nlip-0-5-0/migration/system"/>
        </locations>
    </flyway:migrate>

</target>

それを修正する方法について何か提案はありますか?

4

2 に答える 2

1

2.2 を待っている間、Flyway メタデータ テーブルを初期化する次の「自動」方法を (Oracle DB に対して) 正常にテストしました。

<target name="flyway.init.check">
    <!-- Select on the DB to see if the metadata table is already in place-->
    <sql driver="oracle.jdbc.OracleDriver"
         url="jdbc:oracle:thin:@localhost:1521:WBMD"
         userid="user"
         password="pwd" 
         print="yes" 
         output="temp.properties"
         expandProperties="true" 
         showheaders="false" 
         showtrailers="false" 
         classpathref="flyway.classpath">
        <![CDATA[
        select 'flyway.metadata.initialized=true' from user_tables where table_name = 'schema_version';
        ]]>
    </sql>
    <!-- load as properies the output from the select -->
    <property file="temp.properties" />
    <delete file="temp.properties" quiet="true"/>
</target>

<target name="flyway.init" depends="flyway.init.check" unless="flyway.metadata.initialized">
    <flyway:init  driver="oracle.jdbc.OracleDriver"
                 url="jdbc:oracle:thin:@localhost:1521:WBMD"
                 user="user"
                 password="pwd" 
                 initVersion="0"
                 initDescription="Version table initialization"/>
</target>

<target name="migrate-db" depends="flyway.init">
   ......
</target>

よろしければお楽しみください (おそらく ant-contrib を使用すると、よりシンプルでコンパクトなソリューションを得ることができます)

ダビデ

于 2013-07-10T10:33:55.740 に答える