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

yii migrate command doesn't work with postgresql database

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

但是 "yii migrate" 不适用于 postgresql 数据库。它产生以下错误消息:

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

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

我在 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: 
            'schemaMap' => [
                'pgsql'=> [
                    'class'=>'yii\db\pgsql\Schema',
                    'defaultSchema' => 'public' //specify your schema here
                ],
            ], // PostgreSQL
        ],

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

which php
php -i

我在 Windows 中遇到了同样的问题,但在 Linux 中没有。也许,那来自 driver 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 ...).