Drupal 7更新架构打破

问题描述:

有人可以告诉我,如果我错过了这件事吗?在代码块之后它会一直抛出底部提到的错误。Drupal 7更新架构打破

function license_update_7101() { 

    $schema['license_agreements'] = array(
    'description' => 'License User Agreements', 
    'fields' => array(
     'license_id' => array(
     'description' => 'Primary key for license records', 
     'type'  => 'serial', 
     'not null' => TRUE, 
     'unsigned' => TRUE 
    ), 
     'user_id' => array(
     'description' => 'License agreed to by User ID', 
     'type'  => 'int', 
     'not null' => FALSE, 
     'unsigned' => TRUE, 
     'default'  => '0' 
    ), 
     'product_id' => array(
     'description' => 'Product ID that represents the product this agreement was assigned to.', 
     'type'  => 'int', 
     'not null' => FALSE, 
     'unsigned' => TRUE, 
     'default'  => '0' 
    ), 
     'session' => array(
     'description' => 'Session created during account creation.', 
     'type'  => 'varchar', 
     'length'  => 32, 
     'not null' => FALSE, 
     'default'  => '' 
    ), 
     'agreed' => array(
     'description' => 'Represents if the license was agreed to or not', 
     'type'  => 'int', 
     'size'  => 'tiny', 
     'not null' => FALSE, 
     'unsigned' => TRUE, 
     'default'  => '0' 
    ), 
     'agreement_date' => array(
     'description' => 'Date this license was agreed to by user.', 
     'type'  => 'datetime', 
     'mysql_type' => 'DATETIME', 
     'disp-width' => '11', 
     'not null' => FALSE, 
     'default'  => NULL 
    ), 
     'blog_name' => array(
     'description' => 'URL for actual product license belongs to.', 
     'type'  => 'varchar', 
     'length'  => '128', 
     'not null' => FALSE, 
     'default'  => '' 
    ), 
     'primary key' => array('license_id') 
    ) 
); 

    db_create_table('license_agreements', $schema['license_agreements']); 
} 

错误:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB [error] 
server version for the right syntax to use near 'DEFAULT NULL 
) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'License' at line 9 

真的很想得到这个解决。

谢谢!

因此,有其他开发人员的礼貌来帮我试图找到什么东西吹起来,我设法发现问题,因为我们通过它的工作。

'primary key' => array('license_id') 

我最终注意到,它被嵌入在fields数组中,并且需要在它之外/之后。

因此,修复是作为上下移动该行作为license_agreements阵列的一个数组元素一样简单。问题解决了!