【发布时间】:2017-04-01 23:38:09
【问题描述】:
下面是我的代码,请告诉我我哪里错了..
public function up(){
$this->dbforge->add_field(array(
'id'=> array(
'type' => 'int',
'constraint' => 11,
'auto_increment'=> TRUE,
),
'ip_address'=> array(
'type' => 'VARCHAR',
'constraint'=> '40',
),
'login'=> array(
'type' => 'VARCHAR',
'constraint'=> '50',
),
'time'=> array(
'type' => 'timestamp',
'Default' => 'CURRENT_TIMESTAMP',
'ON UPDATE CURRENT_TIMESTAMP' => TRUE,
),
));
$this->dbforge->add_key('id',TRUE);
$this->dbforge->create_table('login_attempts');
echo "table created";
}
这个错误会在运行迁移时产生
错误号:
1067
“时间”的默认值无效
CREATE TABLE login_attempts (id int(11) NOT NULL AUTO_INCREMENT, ip_address VARCHAR(40) NOT NULL,登录 VARCHAR(50) NOT NULL,时间 时间戳非空默认值'CURRENT_TIMESTAMP',约束 pk_login_attempts PRIMARY KEY(id) ) 默认字符集 = utf8 整理 = utf8_general_ci
文件名:D:/xampp/htdocs/tank_auth/system/database/DB_driver.php
行号:691
【问题讨论】:
标签: codeigniter database-migration