1

我正在尝试使用Phing来部署我的项目。Checkout from SVN和脚本工作得很好,Running Composer但我的数据库的迁移却没有。这是错误消息:

目标“迁移”的执行失败,原因如下:任务以代码 2 退出
sh:无法打开 build/scripts/deploy-.sql:没有这样的文件

似乎 delta 文件不是由 Phing 生成的。

我的Migration脚本如下所示:

<target name="migration" description="Datenbankmigration">
  <property file="${phing.dir}/includes/build.properties"/>
  <propertyprompt propertyName="db.name" defaultValue="${db.name}" promptText="Datenbankname angeben falls nicht der Defaultwert genutzt werden soll. Default:" />
  <propertyprompt propertyName="db.username" defaultValue="${db.username}" promptText="Datenbankbenutzernamen angeben falls nicht der Defaultwert genutzt werden soll. Default:" />
  <propertyprompt propertyName="db.password" defaultValue="" promptText="Datenbankpasswort angeben falls nicht der Defaultwert genutzt werden soll. Default:" />
  <propertyprompt propertyName="db.host" defaultValue="${db.host}" promptText="Host angeben falls nicht der Defaultwert genutzt werden soll. Default:" />

  <!-- load the dbdeploy task -->
  <taskdef name="dbdeploy" classname="phing.tasks.ext.dbdeploy.DbDeployTask" />

  <!-- these two filenames will contain the generated SQL to do the deploy and roll it back -->
  <property name="build.dbdeploy.deployfile" value="${phing.dir}build/scripts/deploy-${DSTAMP}${TSTAMP}.sql" />
  <property name="build.dbdeploy.undofile" value="${build.dir}build/scripts/undo-${DSTAMP}${TSTAMP}.sql" />

  <!-- create the changelog Table -->
  <pdosqlexec url="mysql:host=${db.host};dbname=${db.name}" userid="${db.username}" password="${db.password}">
    <transaction src="build/sql/changelog.sql"/>
  </pdosqlexec>

  <!-- generate the deployment scripts -->
  <dbdeploy
    url="mysql:host=${db.host};dbname=${db.name}"
    userid="${db.username}"
    password="${db.password}"
    dir="${phing.dir}/sql/delta"
    outputfile="${build.dbdeploy.deployfile}"
    undooutputfile="${build.dbdeploy.undofile}" />

  <!-- execute the SQL - Use mysql command line to avoid trouble with large
  files or many statements and PDO -->
  <exec
    command="mysql -h${db.host} -u${db.username} -p${db.password} ${db.name} &lt; ${build.dbdeploy.deployfile}"
    dir="${phing.dir}"
    checkreturn="true"
    output="${phing.dir}/cache/deploy-${DSTAMP}${TSTAMP}.log"
    error="${phing.dir}/cache/deploy-error-${DSTAMP}${TSTAMP}.log"
  />

  <echo msg="Datenbank erfolgreich angelegt"/>

</target>

有谁知道为什么?

4

1 回答 1

1

首先,您似乎忘记了<tstamp />目标中的标签,以便${DSTAMP}and${TSTAMP}变量起作用。

然后你应该像这样定义你的属性:

<property name="build.dbdeploy.deployfile" value="deploy-${DSTAMP}${TSTAMP}.sql" />
<property name="build.dbdeploy.undofile" value="undo-${DSTAMP}${TSTAMP}.sql" />

它们应该自动放置在您在dir参数中指定的目录中。

于 2013-09-06T13:27:50.253 回答