phing dbdeploy 与 postgres

phing dbdeploy with postgres

嗨, 我想将 Phing 和 dbdeploy 与 postgres 数据库结合使用。 问题是我无法使用连接字符串连接到数据库,因为我无法定义密码。 有人对此有解决方案吗? 以下是xml的说明: `

    <!-- 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="scripts/deploy-${DSTAMP}${TSTAMP}.sql" />
    <property name="build.dbdeploy.undofile" value="scripts/undo-${DSTAMP}${TSTAMP}.sql" />

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

    <!-- execute the SQL - Use psql command line to avoid trouble with large
        files or many statements and PDO -->
    <trycatch>
        <try>
            <exec
                command="pqsql -h${db.host} -U${db.username} -p${db.port} -d${db.name} &lt; ${build.dbdeploy.deployfile} -W"
                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 ausgerollt"/>
        </try>
        <catch>
            <echo msg="Fehler beim ausrollen der Datenbank, führe Rollback durch"/>
            <exec
                command="pgsql -h${db.host} -U${db.username} -p${db.port} -d${db.name} &lt; ${build.dbdeploy.undofile}"
                dir="${phing.dir}"
                checkreturn="true"
            />
            <echo msg="Rollback erfolgreich"/>
        </catch>
    </trycatch>



</target>

<!-- ============================================  -->
<!-- Target: writeFiles                            -->
<!-- ============================================  -->
<target name="writeFiles" description="Write all properties in files">

<copy
    file="${dir}config/autoload/local.php.dist"
    tofile="${dir}config/autoload/local.php"
    overwrite="true"
>
    <filterchain>
        <replacetokens begintoken="@" endtoken="@">
            <token key="db.host" value="${db.host}"/>
            <token key="db.username" value="${db.username}"/>
            <token key="db.password" value="${db.password}"/>
            <token key="db.name" value="${db.name}"/>
            <token key="db.port" value="${db.port}"/>
        </replacetokens>
    </filterchain>
</copy>
<echo>local.php geschrieben.</echo>
</target>`

您可以为系统用户(将执行 phing 脚本的用户)创建一个 password file