给tag列创建index失败

新手提问 · sukeay · 于 2年前 发布 · 1537 次阅读

*** applying m150104_071047_init_blog

> create table {{%post_meta}} ... done (time: 0.022s)
> create index type on {{%post_meta}} (type) ... done (time: 0.031s)
> create table {{%post}} ... done (time: 0.120s)
> create index post_meta_id on {{%post}} (post_meta_id) ... done (time: 0.162s)
> create index tags on {{%post}} (tags) ...Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

The SQL being executed was: ALTER TABLE post ADD INDEX tags (tags)'

in D:\workspace\cocosmir\getyii\vendor\yiisoft\yii2\db\Schema.php:637

Error Info: Array (

[0] => 42000
[1] => 1071
[2] => Specified key was too long; max key length is 767 bytes

)

Stack trace: #0 D:\workspace\cocosmir\getyii\vendor\yiisoft\yii2\db\Command.php(854): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE `po...')

数据库版本不对?

共收到 1 条回复
forecho#12年前 0 个赞

已经给出提示了,你要根据提示作出相应的修改。

tags 是什么字段类型?

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册