我有一个表,我想添加如下索引:
@Index(columns={"child_id", "abilities"}),
@Index(columns={"parent_id", "abilities"}),
。。。
* @ORM\Column(type="json_array", length=256)
*/
protected $abilities;
但是,即使在迁移中添加了适当的限制,也会:
$this->addSql('CREATE INDEX IDX_1088BF61DD62C21BB8388DA4 ON xxx (child_id, abilities(512))');
$this->addSql('CREATE INDEX IDX_1088BF61727ACA70B8388DA4 ON xxx (parent_id, abilities(512))');
运行重新创建数据库的测试时,会出现如下错误:
执行'
CREATE TABLE xxx (
id INT AUTO_INCREMENT NOT NULL,
parent_id INT DEFAULT NULL,
child_id INT DEFAULT NULL,
type VARCHAR(125) NOT NULL,
abilities LONGTEXT NOT NULL COMMENT '(DC2Type:json_array)',
created_at DATETIME NOT NULL,
modified_at DATETIME NOT NULL,
INDEX IDX_1088BF61727ACA70 (parent_id),
INDEX IDX_1088BF61DD62C21B (child_id),
INDEX IDX_1088BF61DD62C21B8CDE5729 (child_id, type),
INDEX IDX_1088BF61727ACA708CDE5729 (parent_id, type),
INDEX IDX_1088BF618CDE5729 (type),
INDEX IDX_1088BF61DD62C21BB8388DA4 (child_id, abilities),
INDEX IDX_1088BF61727ACA7 0B8388DA4 (parent_id, abilities),
INDEX IDX_1088BF61B8388DA4 (abilities),
UNIQUE INDEX UNIQ_1088BF61727ACA70DD62C21B (parent_id, child_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
':
SQLSTATE[42000]:语法错误或访问冲突:1170 BLOB/TEXT
键规范中使用的“能力”列没有键长度
要在这些列上成功创建索引,我需要做什么?