10

我第一次尝试在我正在开发的 Propel 项目中使用迁移(因此我不必重新插入 15MB 的数据),但遇到了一些困难。我在架构中进行了更改并运行了propel-gen diff. 我首先收到一个错误,它无法找到我的buildtime-conf.xml文件。我还没有做一个(因为没有必要),但读到结构应该与runtime-conf.xml. 我复制runtime-conf.xmlbuildtime-conf.xml. 现在收到以下错误:

[propel-sql-diff] Reading databases structure...
[phingcall] Unable to find adapter for datasource [project].
Execution of target "sql-diff" failed for the following reason: /var/www/project/vendor/propel/propel1/generator/build-propel.xml:317:26: Execution of the target buildfile failed. Aborting.
    [phing] /var/www/project/vendor/propel/propel1/generator/build-propel.xml:317:26: Execution of the target buildfile failed. Aborting.

我的运行时和构建时文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <propel>
        <datasources default="project">
            <datasource id="project">
                <adapter>pgsql</adapter>
                <connection>
                    <dsn>pgsql:host=###.###.###.###;dbname=database</dsn>
                    <user>USER</user>
                    <password>PASS</password>
                </connection>
            </datasource>
        </datasources>
    </propel>
</config>

我的模式是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<database name="project" defaultIdMethod="native">
    <table schema="accounts" name="accounts" phpName="Account" package="accounts">
        <column />
    </table>
</database>

我尝试将 buildtime-conf 更改为<datasource id="testing">并将错误更改为Unable to find adapter for datasource [testing]. 因此,据我所知,错误在于实际的 buildtime-conf 文件(而不是模式)。我想也许 Propel 找不到 PostgreSQL 的适配器(即使它在我的 runtime-conf 中运行良好),所以我尝试将我的适配器更改为mysql. 它提出了同样的无法找到适配器错误。

我完全迷路了,想法?

更新:所以我能够进入/Propel/runtime/lib/Propel.php并找到Unable to find adapter引发异常的行。我通过添加该行手动定义了变量self::$configuration['datasources'][$name]['adapter'] = 'pgsql',它可以工作。这显然目前没有验证有用,因为如果不重做此更改,我将无法更新 Propel。我倾倒self::$configuration在 Propel.php 中,它是NULL,任何想法为什么?

4

2 回答 2

3

在最新的 Propel 稳定版本(1.7.1)中,不可能添加以下代码:

self::$configuration['datasources'][$name]['adapter'] = 'mysql';

导致以下错误:

Indirect modification of overloaded element of PropelConfiguration has no effect

这就是为什么,如果您只有一个适配器,您可以使用:

/*
if (!isset(self::$configuration['datasources'][$name]['adapter'])) {
    throw new PropelException("Unable to find adapter for datasource [" . $name . "].");
}
*/
$db = DBAdapter::factory('mysql');
// register the adapter for this name
self::$adapterMap[$name] = $db;

此错误仅在使用 ./propel-gen diff 时发生。还是很奇怪的。希望他们尽快修复。

于 2014-03-08T14:29:19.007 回答
3

看起来像切换 Composer 依赖项来dev-master解决这个问题 -在撰写本文时,当前版本 (1.7.1) 和 master 之间有20 个提交差异。迁移补丁专门在这里

希望在适当的时候发布 1.7.2 版本,尽管应该注意团队的开发工作目前可能会集中在 Propel2 上(仍处于 alpha 阶段)。

于 2015-02-05T21:14:47.120 回答