yii migrate命令不适用于postgresql数据库

时间:2015-07-30 17:45:48

标签: postgresql yii2 migrate

我安装了Yii 2高级模板。 " yii迁移" CMD中的命令与默认的MySQL数据库完美配合,它按预期使用表 migration user 填充数据库(参见此处解释的步骤3:https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md

但是" yii迁移"不使用postgresql数据库。它会产生以下错误消息:

error message in command line interface (CMD)

出了什么问题,或者缺少什么?如果我手动创建数据表(已经过测试),Yii 2框架可以读取数据表,但是迁移命令并不想工作。

postgresql所需的pdo扩展在php.ini文件中被注释掉了。网页 requirements.php 显示"已通过" (没有错误或警告)PDO PostgreSQL扩展。

我的db连接配置在common / config / main-local.php中:

 'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'tablePrefix' => 'tbl_',
            'dsn' => 'pgsql:host=localhost;port=5432;dbname=mytestdb',
            'username' => 'postgres',
            'password' => 'tuparnix',
            'charset' => 'utf8',
            // see: http://stackoverflow.com/questions/26436024/how-to-set-default-schema-in-yii2
            'schemaMap' => [
                'pgsql'=> [
                    'class'=>'yii\db\pgsql\Schema',
                    'defaultSchema' => 'public' //specify your schema here
                ],
            ], // PostgreSQL
        ],

2 个答案:

答案 0 :(得分:1)

你的命令行php和你的web服务器php是一个不同的PHP。 你需要在命令行php.ini中注释你的postgres驱动程序。 请在命令行中运行这些以获取更多信息(我不确定这些命令的windows版本是什么,请chk)

which php
php -i

答案 1 :(得分:0)

我在Windows中遇到同样的问题但不是Linux。也许,那来自驱动程序php_pdo_pgsql + libpq.dll。 你的phpinfo(),Postgresql 8.3.3(windows)或9.2.1(linux)中哪个版本不兼容。从这一边看。 您在Windows上使用的服务器是什么? (xampp,easyphp,WampServer)和什么版本的php(5.4,5.5,5.6 ......)。

相关问题