首页 > 解决方案 > Drupal 7 在使用 postgres 为模块创建模式时获取 PDOException

问题描述

我已经创建了下面的模式来.install为我在 drupal7 中的一个模块创建一个文件表

$schema['mymodule_categories'] = [
        'description' => 'Module Category',
        'fields' => [
            'id' => [
                'description' => 'The primary identifer for a category',
                'type' => 'serial',
                'unsigned' => true,
                'size' => 'small',
                'not null' => true,
            ],
            'title' => [
                'description' => 'The Title or the name of the category',
                'type' => 'varchar',
                'length' => 255,
            ],
            'primary key' => ['id'],
        ],
    ];

但是当我启用我的模块时,我收到以下错误。

*Notice: Undefined index: type in DatabaseSchema_pgsql->processField() (line 229 of /my/location/projects/project/includes/database/pgsql/schema.inc).
*Notice: Undefined index: :normal in DatabaseSchema_pgsql->processField() (line 229 of /my/location/projects/project/includes/database/pgsql/schema.inc).
*PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near ")" LINE 5: ) ^: CREATE TABLE {mymodule_categories} ( id serial CHECK (id >= 0), title varchar(255), primary key ); Array ( ) in db_create_table() (line 2827 of /my/location/projects/project/includes/database/database.inc)

我对 drupal cms 本身很陌生,最重要的是,我的项目基于 Postgres。那么有没有办法解决这个问题呢?

标签: phppostgresqldrupaldrupal-7drupal-modules

解决方案


推荐阅读