【发布时间】:2015-07-30 17:45:47
【问题描述】:
我安装了 Yii 2 高级模板。 CMD 中的“yii migrate”命令与默认 MySQL 数据库完美配合,它按预期使用表 migration 和 user 填充数据库(参见此处解释的步骤 3:@987654321 @)
但是“yii migrate”不适用于 postgresql 数据库。它会产生以下错误消息:
出了什么问题,或者缺少什么?如果我手动创建数据表(已经过测试),Yii 2 框架可以读取数据表,但是 migrate 命令不想工作。
postgresql 所需的 pdo 扩展在 php.ini 文件中被注释掉了。网页 requirements.php 显示 PDO PostgreSQL 扩展“通过”(没有错误或警告)。
common/config/main-local.php中我的db连接配置:
'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
],
【问题讨论】:
标签: postgresql yii2 migrate