Propel ORM:更改diff和migrate的连接设置

时间:2015-10-29 17:18:54

标签: php mysql vagrant propel propel2

所以我目前正在使用Propel ORM(v2.00-dev)开发一个小项目,我想我第一次尝试使用Vagrant。

我设置了vagrant服务器以允许外部MySQL连接,并构建了以下配置文件,所以每次我想从命令行运行propel时我都不必ssh进入服务器

{
  "propel": {
      "paths": {
        "outputDir": "./propel/",
        "phpDir": "./propel/model/",
        "sqlDir": "./propel/sql",
        "phpConfDir": "./propel/conf"
      },
      "database": {
        "connections": {
          "project-local": {
            "adapter": "mysql",
            "dsn": "mysql:host=localhost;dbname=scotchbox",
            "user": "root",
            "password": "root",
            "attributes": []
          },
          "project-remote": {
            "adapter": "mysql",
            "dsn": "mysql:host=192.168.33.10;dbname=scotchbox",
            "user": "root",
            "password": "root",
            "attributes": []
          }
        }
      },
      "runtime": {
        "defaultConnection": "project-local",
        "connections": ["projeect-local","project-remote"]
      },
      "generator": {
        "defaultConnection": "project-remote",
        "connections": ["project-remote","project-local"]
      }
    }
  }

schema.xml配对:

<database name="project-remote">
    <!-- lots of tables in here -->
</database>

到目前为止,这项工作一直很顺利。应用程序使用project-local运行,当我从命令行运行propel时,它会按预期切换到project-remote

但是当我尝试运行propel diff时,我收到以下错误:

[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

这表明在运行差异时,Propel正在尝试使用runtime连接设置而不是generator连接设置。有没有办法可以改变这个?我已经检查了配置文档,但我无法看到有关设置连接的任何信息。

我还注意到diff命令有一个--connection参数,但我找不到任何信息,也无法弄清楚如何使用它。我试过了:

propel diff --connection=project-remote

propel diff --connection="project-remote"

两者都会导致以下错误

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
The path "propel.database.connections..adapter" cannot contain an empty value, but got "".

那么,有没有人对如何指定推进差异的连接(可能是迁移)有任何想法?

0 个答案:

没有答案